From 320f48b08b5ca6dd023c5a325b19bf372d76a75b Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Thu, 10 Mar 2022 12:40:57 +0300 Subject: [PATCH] ws2_32: Manage shorter length for IPV6_DONTFRAG. Signed-off-by: Paul Gofman Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/ws2_32/socket.c | 14 +++++++++++++- dlls/ws2_32/tests/sock.c | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index c666c758af2..ba9341befa6 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -1810,6 +1810,12 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl switch(optname) { case IPV6_DONTFRAG: + if (*optlen < 1 || !optval) + { + SetLastError( WSAEFAULT ); + return SOCKET_ERROR; + } + if (*optlen < sizeof(DWORD)) *optlen = 1; return server_getsockopt( s, IOCTL_AFD_WINE_GET_IPV6_DONTFRAG, optval, optlen ); case IPV6_HOPLIMIT: @@ -3161,7 +3167,13 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPV6_ADD_MEMBERSHIP, optval, optlen ); case IPV6_DONTFRAG: - return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPV6_DONTFRAG, optval, optlen ); + if (!optlen || !optval) + { + SetLastError( WSAEFAULT ); + return SOCKET_ERROR; + } + memcpy( &value, optval, min( optlen, sizeof(value) )); + return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPV6_DONTFRAG, (char *)&value, sizeof(value) ); case IPV6_DROP_MEMBERSHIP: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPV6_DROP_MEMBERSHIP, optval, optlen ); diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index ea1f939c5f3..c9c8b0ab78f 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1189,6 +1189,7 @@ static void test_set_getsockopt(void) {AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_RECVTTL, FALSE, {0, 0, 4}, {0}, TRUE, TRUE}, {AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_TOS, TRUE, {1, 1, 4}, {0}, FALSE}, {AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_TTL, TRUE, {1, 1, 4}, {0}, FALSE}, + {AF_INET6, SOCK_STREAM, IPPROTO_IPV6, IPV6_DONTFRAG, TRUE, {1, 1, 4}, {0}, TRUE, TRUE}, }; SOCKET s, s2; int i, j, err, lasterr;