ws2_32: Manage shorter length for SO_DONTROUTE.

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2022-03-08 12:22:50 +03:00 committed by Alexandre Julliard
parent a73cb3f137
commit 26c2670203
2 changed files with 13 additions and 5 deletions

View File

@ -1511,13 +1511,14 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl
/* As mentioned in setsockopt, Windows ignores this, so we /* As mentioned in setsockopt, Windows ignores this, so we
* always return true here */ * always return true here */
case SO_DONTROUTE: case SO_DONTROUTE:
if (*optlen < sizeof(BOOL) || !optval) if (*optlen < 1 || !optval)
{ {
SetLastError( WSAEFAULT ); SetLastError( WSAEFAULT );
return SOCKET_ERROR; return SOCKET_ERROR;
} }
*(BOOL *)optval = TRUE; *optval = TRUE;
*optlen = sizeof(BOOL); *optlen = 1;
SetLastError( ERROR_SUCCESS );
return 0; return 0;
case SO_ERROR: case SO_ERROR:
@ -2859,7 +2860,13 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int
/* For some reason the game GrandPrixLegends does set SO_DONTROUTE on its /* For some reason the game GrandPrixLegends does set SO_DONTROUTE on its
* socket. According to MSDN, this option is silently ignored.*/ * socket. According to MSDN, this option is silently ignored.*/
case SO_DONTROUTE: case SO_DONTROUTE:
TRACE("Ignoring SO_DONTROUTE\n"); TRACE( "Ignoring SO_DONTROUTE.\n" );
if (optlen <= 0)
{
SetLastError( optlen ? WSAENOBUFS : WSAEFAULT );
return -1;
}
SetLastError( ERROR_SUCCESS );
return 0; return 0;
/* Stops two sockets from being bound to the same port. Always happens /* Stops two sockets from being bound to the same port. Always happens

View File

@ -1171,6 +1171,7 @@ static void test_set_getsockopt(void)
{ {
{AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_BROADCAST, TRUE, {1, 1, 4}, {0, 0xdead0001, 0}, TRUE, TRUE}, {AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_BROADCAST, TRUE, {1, 1, 4}, {0, 0xdead0001, 0}, TRUE, TRUE},
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_DONTLINGER, TRUE, {1, 1, 4}, {0, 0xdead0001, 0}, TRUE, TRUE}, {AF_INET, SOCK_STREAM, SOL_SOCKET, SO_DONTLINGER, TRUE, {1, 1, 4}, {0, 0xdead0001, 0}, TRUE, TRUE},
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_DONTROUTE, TRUE, {1, 1, 1}, {0}, TRUE},
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_RCVTIMEO, FALSE, {1, 2, 4}, {0}, TRUE}, {AF_INET, SOCK_STREAM, SOL_SOCKET, SO_RCVTIMEO, FALSE, {1, 2, 4}, {0}, TRUE},
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_SNDTIMEO, FALSE, {1, 2, 4}, {0}, TRUE}, {AF_INET, SOCK_STREAM, SOL_SOCKET, SO_SNDTIMEO, FALSE, {1, 2, 4}, {0}, TRUE},
{AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_MULTICAST_LOOP, TRUE, {1, 1, 4}, {0}, TRUE, TRUE}, {AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_MULTICAST_LOOP, TRUE, {1, 1, 4}, {0}, TRUE, TRUE},