Module: wine Branch: stable Commit: f1ad73a2c3f18f1f434aa2e3fd9649ab1bb121fb URL: https://source.winehq.org/git/wine.git/?a=commit;h=f1ad73a2c3f18f1f434aa2e3f...
Author: Hans Leidekker hans@codeweavers.com Date: Tue Aug 11 14:11:05 2020 +0200
ws2_32: Avoid a crash in WS_getaddrinfo when the specified service doesn't exist.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49656 Signed-off-by: Hans Leidekker hans@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit a6d9f46b25a481648a2a06ed8d1594fc59a4e313) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/ws2_32/socket.c | 2 +- dlls/ws2_32/tests/sock.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 1ca750764a9..374eec37f2e 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -6854,7 +6854,7 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr result = getaddrinfo(node, servname, punixhints, &unixaires);
if (result && (!hints || !(hints->ai_flags & WS_AI_NUMERICHOST)) - && (!strcmp(fqdn, node) || (!strncmp(fqdn, node, hostname_len) && !node[hostname_len]))) + && node && (!strcmp(fqdn, node) || (!strncmp(fqdn, node, hostname_len) && !node[hostname_len]))) { /* If it didn't work it means the host name IP is not in /etc/hosts, try again * by sending a NULL host and avoid sending a NULL servname too because that diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 60c5dfc63fb..bf1aeefb852 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -8070,6 +8070,10 @@ static void test_getaddrinfo(void) ok(0, "test %d: getaddrinfo failed with %d (err %d)\n", i, ret, err); } } + + memset(&hint, 0, sizeof(hint)); + ret = pgetaddrinfo(NULL, "nonexistentservice", &hint, &result); + ok(ret == WSATYPE_NOT_FOUND, "got %d\n", ret); }
static void test_ConnectEx(void)