Commit f7c48f23 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ws2_32: Manage shorter length for SO_KEEPALIVE.

parent 79a19b2b
......@@ -1525,6 +1525,12 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl
return server_getsockopt( s, IOCTL_AFD_WINE_GET_SO_ERROR, optval, optlen );
case SO_KEEPALIVE:
if (*optlen < 1 || !optval)
{
SetLastError( WSAEFAULT );
return SOCKET_ERROR;
}
*optlen = 1;
return server_getsockopt( s, IOCTL_AFD_WINE_GET_SO_KEEPALIVE, optval, optlen );
case SO_LINGER:
......@@ -2827,7 +2833,13 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int
return -1;
case SO_KEEPALIVE:
return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_KEEPALIVE, optval, optlen );
if (optlen <= 0 || !optval)
{
SetLastError( optlen ? WSAENOBUFS : WSAEFAULT );
return SOCKET_ERROR;
}
value = *optval;
return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_KEEPALIVE, (char *)&value, sizeof(value) );
case SO_LINGER:
return server_setsockopt( s, IOCTL_AFD_WINE_SET_SO_LINGER, optval, optlen );
......
......@@ -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_STREAM, SOL_SOCKET, SO_DONTLINGER, TRUE, {1, 1, 4}, {0, 0xdead0001, 0}, TRUE, TRUE},
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_KEEPALIVE, TRUE, {1, 1, 1}, {0}, 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_SNDTIMEO, FALSE, {1, 2, 4}, {0}, TRUE},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment