mirror of
https://github.com/reactos/reactos.git
synced 2025-01-07 06:45:24 +00:00
[WS2_32_NEW]
- Add missing SEH in getsockopt/setsockopt CORE-10440 svn path=/trunk/; revision=69823
This commit is contained in:
parent
e67e24eeca
commit
facf3ecba9
3 changed files with 75 additions and 28 deletions
|
@ -51,7 +51,7 @@ add_library(ws2_32_new SHARED
|
|||
${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)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <winuser.h>
|
||||
#include <ws2spi.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
#include <pseh/pseh2.h>
|
||||
|
||||
/* Winsock Helper Header */
|
||||
#include <ws2help.h>
|
||||
|
|
|
@ -272,17 +272,29 @@ getsockopt(IN SOCKET s,
|
|||
if ((level == SOL_SOCKET) && (optname == SO_OPENTYPE))
|
||||
{
|
||||
/* Validate size */
|
||||
if (!(optlen) || (*optlen < sizeof(INT)))
|
||||
Status = ERROR_SUCCESS;
|
||||
_SEH2_TRY
|
||||
{
|
||||
/* Fail */
|
||||
SetLastError(WSAEFAULT);
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
if (!(optlen) || (*optlen < sizeof(INT)))
|
||||
{
|
||||
/* Fail */
|
||||
Status = SOCKET_ERROR;
|
||||
SetLastError(WSAEFAULT);
|
||||
_SEH2_LEAVE;
|
||||
}
|
||||
|
||||
/* Set the open type */
|
||||
*optval = (CHAR)Thread->OpenType;
|
||||
*optlen = sizeof(INT);
|
||||
return ERROR_SUCCESS;
|
||||
/* Set the open type */
|
||||
*optval = (CHAR)Thread->OpenType;
|
||||
*optlen = sizeof(INT);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = SOCKET_ERROR;
|
||||
SetLastError(WSAEFAULT);
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Get the Socket Context */
|
||||
|
@ -292,27 +304,42 @@ getsockopt(IN SOCKET s,
|
|||
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 @@ getsockopt(IN SOCKET s,
|
|||
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 @@ setsockopt(IN SOCKET s,
|
|||
}
|
||||
|
||||
/* 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 */
|
||||
|
|
Loading…
Reference in a new issue