Jacek Caban : ws2_32: Don' t try to match host name in getaddrinfo if AI_NUMERICHOST hint is specified.

Alexandre Julliard julliard at winehq.org
Tue May 16 16:05:10 CDT 2017


Module: wine
Branch: master
Commit: efdb722c179a476e728c9fe22d738f5d90ac23d5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=efdb722c179a476e728c9fe22d738f5d90ac23d5

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue May 16 17:47:45 2017 +0200

ws2_32: Don't try to match host name in getaddrinfo if AI_NUMERICHOST hint is specified.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/socket.c     | 2 +-
 dlls/ws2_32/tests/sock.c | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index e464b58..44bd667 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -6620,7 +6620,7 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr
     /* getaddrinfo(3) is thread safe, no need to wrap in CS */
     result = getaddrinfo(node, servname, punixhints, &unixaires);
 
-    if (result && !strcmp(hostname, node))
+    if (result && (!hints || !(hints->ai_flags & WS_AI_NUMERICHOST)) && !strcmp(hostname, node))
     {
         /* 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 57455c0..677a750 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -7425,6 +7425,14 @@ static void test_getaddrinfo(void)
     ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
     pfreeaddrinfo(result);
 
+    hint.ai_flags = AI_NUMERICHOST;
+    result = (void*)0xdeadbeef;
+    ret = pgetaddrinfo("localhost", "80", &hint, &result);
+    ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", WSAGetLastError());
+    ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected WSAHOST_NOT_FOUND, got %d\n", WSAGetLastError());
+    ok(!result, "result = %p\n", result);
+    hint.ai_flags = 0;
+
     /* try to get information from the computer name, result is the same
      * as if requesting with an empty host name. */
     ret = pgetaddrinfo(name, NULL, NULL, &result);




More information about the wine-cvs mailing list