Author: tfaber
Date: Sat Nov 7 08:30:00 2015
New Revision: 69823
URL:
http://svn.reactos.org/svn/reactos?rev=69823&view=rev
Log:
[WS2_32_NEW]
- Add missing SEH in getsockopt/setsockopt
CORE-10440
Modified:
trunk/reactos/dll/win32/ws2_32_new/CMakeLists.txt
trunk/reactos/dll/win32/ws2_32_new/inc/ws2_32.h
trunk/reactos/dll/win32/ws2_32_new/src/sockctrl.c
Modified: trunk/reactos/dll/win32/ws2_32_new/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32_new/CMake…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32_new/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32_new/CMakeLists.txt [iso-8859-1] Sat Nov 7 08:30:00
2015
@@ -51,7 +51,7 @@
${CMAKE_CURRENT_BINARY_DIR}/ws2_32_new.def)
set_module_type(ws2_32_new win32dll)
+target_link_libraries(ws2_32_new ${PSEH_LIB})
add_importlibs(ws2_32_new user32 advapi32 dnsapi ws2help msvcrt kernel32 ntdll)
add_pch(ws2_32_new inc/ws2_32.h SOURCE)
-target_link_libraries(ws2_32_new wine)
add_cd_file(TARGET ws2_32_new DESTINATION reactos/system32 FOR all)
Modified: trunk/reactos/dll/win32/ws2_32_new/inc/ws2_32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32_new/inc/w…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32_new/inc/ws2_32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32_new/inc/ws2_32.h [iso-8859-1] Sat Nov 7 08:30:00 2015
@@ -28,6 +28,7 @@
#include <winuser.h>
#include <ws2spi.h>
#include <ndk/rtlfuncs.h>
+#include <pseh/pseh2.h>
/* Winsock Helper Header */
#include <ws2help.h>
Modified: trunk/reactos/dll/win32/ws2_32_new/src/sockctrl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32_new/src/s…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32_new/src/sockctrl.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32_new/src/sockctrl.c [iso-8859-1] Sat Nov 7 08:30:00
2015
@@ -272,17 +272,29 @@
if ((level == SOL_SOCKET) && (optname == SO_OPENTYPE))
{
/* Validate size */
- if (!(optlen) || (*optlen < sizeof(INT)))
- {
- /* Fail */
+ Status = ERROR_SUCCESS;
+ _SEH2_TRY
+ {
+ if (!(optlen) || (*optlen < sizeof(INT)))
+ {
+ /* Fail */
+ Status = SOCKET_ERROR;
+ SetLastError(WSAEFAULT);
+ _SEH2_LEAVE;
+ }
+
+ /* Set the open type */
+ *optval = (CHAR)Thread->OpenType;
+ *optlen = sizeof(INT);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = SOCKET_ERROR;
SetLastError(WSAEFAULT);
- return SOCKET_ERROR;
- }
-
- /* Set the open type */
- *optval = (CHAR)Thread->OpenType;
- *optlen = sizeof(INT);
- return ERROR_SUCCESS;
+ }
+ _SEH2_END;
+
+ return Status;
}
/* Get the Socket Context */
@@ -292,27 +304,42 @@
if ((level == SOL_SOCKET) && (optname == SO_PROTOCOL_INFOA))
{
/* Validate size and pointers */
- if(!(optval) ||
- !(optlen) ||
- (*optlen < sizeof(WSAPROTOCOL_INFOA)))
+ ErrorCode = NO_ERROR;
+ _SEH2_TRY
{
- /* Set return size */
- *optlen = sizeof(WSAPROTOCOL_INFOA);
-
+ if (!(optval) ||
+ !(optlen) ||
+ (*optlen < sizeof(WSAPROTOCOL_INFOA)))
+ {
+ /* Set return size and error code */
+ *optlen = sizeof(WSAPROTOCOL_INFOA);
+ ErrorCode = WSAEFAULT;
+ _SEH2_LEAVE;
+ }
+
+ /* It worked. Save the values */
+ OldOptLen = *optlen;
+ OldOptVal = optval;
+
+ /* Hack them so WSP will know how to deal with it */
+ *optlen = sizeof(WSAPROTOCOL_INFOW);
+ optval = (PCHAR)&ProtocolInfo;
+ optname = SO_PROTOCOL_INFOW;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ ErrorCode = WSAEFAULT;
+ }
+ _SEH2_END;
+
+ /* Did we encounter invalid parameters? */
+ if (ErrorCode != NO_ERROR)
+ {
/* Dereference the socket and fail */
WsSockDereference(Socket);
- SetLastError(WSAEFAULT);
+ SetLastError(ErrorCode);
return SOCKET_ERROR;
}
-
- /* It worked. Save the values */
- OldOptLen = *optlen;
- OldOptVal = optval;
-
- /* Hack them so WSP will know how to deal with it */
- *optlen = sizeof(WSAPROTOCOL_INFOW);
- optval = (PCHAR)&ProtocolInfo;
- optname = SO_PROTOCOL_INFOW;
}
/* Make the call */
@@ -338,7 +365,15 @@
OldOptVal);
/* Return the length */
- *optlen = OldOptLen;
+ _SEH2_TRY
+ {
+ *optlen = OldOptLen;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ ErrorCode = WSAEFAULT;
+ }
+ _SEH2_END;
/* Return success if this worked */
if (ErrorCode == ERROR_SUCCESS) return Status;
@@ -392,8 +427,19 @@
}
/* Set the open type */
- Thread->OpenType = *optval;
- return ERROR_SUCCESS;
+ Status = ERROR_SUCCESS;
+ _SEH2_TRY
+ {
+ Thread->OpenType = *optval;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = SOCKET_ERROR;
+ SetLastError(WSAEFAULT);
+ }
+ _SEH2_END;
+
+ return Status;
}
/* Get the Socket Context */