From 8fef57b1ef5c81a73441bae6288404f7bb169043 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 8 Mar 2022 12:22:47 +0300 Subject: [PATCH] ws2_32/tests: Add tests for zero option length in test_set_getsockopt(). Signed-off-by: Paul Gofman Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/ws2_32/tests/sock.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 1fc8d132b63..0fab10b4d70 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1459,6 +1459,27 @@ static void test_set_getsockopt(void) } ok(size == (test_optsize[i].optname == SO_OPENTYPE ? 4 : -1), "Got unexpected size %d.\n", size); + if (test_optsize[i].level == SOL_SOCKET && test_optsize[i].bool_value) + { + expected_err = 0; + expected_last_error = 0; + } + else + { + expected_err = -1; + expected_last_error = WSAEFAULT; + } + value = 1; + SetLastError(0xdeadbeef); + err = setsockopt(s2, test_optsize[i].level, test_optsize[i].optname, (char*)&value, 0); + ok(err == expected_err, "Unexpected setsockopt result %d.\n", err); + ok(WSAGetLastError() == expected_last_error, "Unexpected WSAGetLastError() %u.\n", WSAGetLastError()); + + size = 0; + err = getsockopt(s2, test_optsize[i].level, test_optsize[i].optname, (char*)&value, &size); + ok(err == -1, "Unexpected getsockopt result %d.\n", err); + ok(WSAGetLastError() == WSAEFAULT, "Unexpected WSAGetLastError() %u.\n", WSAGetLastError()); + expected_size = test_optsize[i].sizes[2]; if (expected_size == 1) expected_value = 0xdeadbe00;