From d2c4ad762fd896f5984ea3855b3786437674377e Mon Sep 17 00:00:00 2001 From: hater <7element@mail.bg> Date: Wed, 4 Nov 2015 11:38:32 +0200 Subject: [PATCH] Fix get/set opts. disable debug messages --- reactos/dll/win32/ws2_32_new/src/sockctrl.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/ws2_32_new/src/sockctrl.c b/reactos/dll/win32/ws2_32_new/src/sockctrl.c index 4b96f8e..cb34414 100644 --- a/reactos/dll/win32/ws2_32_new/src/sockctrl.c +++ b/reactos/dll/win32/ws2_32_new/src/sockctrl.c @@ -10,7 +10,7 @@ #include -//#define NDEBUG +#define NDEBUG #include /* FUNCTIONS *****************************************************************/ @@ -280,8 +280,14 @@ getsockopt(IN SOCKET s, } /* Set the open type */ - *optval = (CHAR)Thread->OpenType; *optlen = sizeof(INT); + if (!optval) + { + /* Fail */ + SetLastError(WSAEINVAL); + return SOCKET_ERROR; + } + *(INT *)optval = Thread->OpenType; return ERROR_SUCCESS; } @@ -297,7 +303,7 @@ getsockopt(IN SOCKET s, (*optlen < sizeof(WSAPROTOCOL_INFOA))) { /* Set return size */ - *optlen = sizeof(WSAPROTOCOL_INFOA); + if(optlen) *optlen = sizeof(WSAPROTOCOL_INFOA); /* Dereference the socket and fail */ WsSockDereference(Socket); @@ -384,7 +390,7 @@ setsockopt(IN SOCKET s, if (level == SOL_SOCKET && optname == SO_OPENTYPE) { /* Validate size */ - if (optlen < sizeof(INT)) + if (!(optval) || optlen < sizeof(INT)) { /* Fail */ SetLastError(WSAEFAULT); @@ -396,6 +402,14 @@ setsockopt(IN SOCKET s, return ERROR_SUCCESS; } + /* Check invalid buffer */ + if (IS_INTRESOURCE(optval)) + { + /* Fail */ + SetLastError(WSAEFAULT); + return SOCKET_ERROR; + } + /* Get the Socket Context */ if ((Socket = WsSockGetSocket(s))) { -- 1.9.5.msysgit.0