From bde4e36208982d1ca4204d780e92bf62c7ea1249 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Fri, 23 Feb 2007 15:41:10 +0100 Subject: [PATCH] ws2_32: Handle NULL argument in inet_addr. --- dlls/ws2_32/socket.c | 1 + dlls/ws2_32/tests/sock.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index e7a58463cf5..1d007a9e32e 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -2175,6 +2175,7 @@ int WINAPI WSAHtons(SOCKET s, WS_u_short hostshort, WS_u_short *lpnetshort) */ WS_u_long WINAPI WS_inet_addr(const char *cp) { + if (!cp) return INADDR_NONE; return inet_addr(cp); } diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 970e27aa62e..c5bf766aaf9 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1491,7 +1491,7 @@ done: closesocket(server_socket); } -static void test_extendedSocketOptions() +static void test_extendedSocketOptions(void) { WSADATA wsa; SOCKET sock; @@ -1565,7 +1565,7 @@ static void test_extendedSocketOptions() WSACleanup(); } -static void test_getsockname() +static void test_getsockname(void) { WSADATA wsa; SOCKET sock; @@ -1612,6 +1612,14 @@ static void test_getsockname() WSACleanup(); } +static void test_inet_addr(void) +{ + u_long addr; + + addr = inet_addr(NULL); + ok(addr == INADDR_NONE, "inet_addr succeeded unexpectedly\n"); +} + /**************** Main program ***************/ START_TEST( sock ) @@ -1643,6 +1651,7 @@ START_TEST( sock ) test_select(); test_accept(); test_getsockname(); + test_inet_addr(); Exit(); }