From 0813b21bc89673b00b42036453c0b70daa6636ff Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 19 Aug 2012 07:32:47 +0000 Subject: [PATCH] [WS2_32] - Set last error inside getaddrinfo to properly mask some non-fatal errors generated by adns svn path=/trunk/; revision=57107 --- reactos/dll/win32/ws2_32/misc/ns.c | 45 ++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/reactos/dll/win32/ws2_32/misc/ns.c b/reactos/dll/win32/ws2_32/misc/ns.c index 01a43ae1b0f..4dc5aba5059 100644 --- a/reactos/dll/win32/ws2_32/misc/ns.c +++ b/reactos/dll/win32/ws2_32/misc/ns.c @@ -1598,14 +1598,24 @@ getaddrinfo(const char FAR * nodename, DNS_STATUS dns_status; PDNS_RECORD dp, currdns; struct sockaddr_in *sin; + INT error; if (res == NULL) - return WSAEINVAL; + { + error = WSAEINVAL; + goto End; + } if (nodename == NULL && servname == NULL) - return WSAHOST_NOT_FOUND; + { + error = WSAHOST_NOT_FOUND; + goto End; + } if (!WSAINITIALIZED) - return WSANOTINITIALISED; + { + error = WSANOTINITIALISED; + goto End; + } if (servname) { @@ -1619,14 +1629,20 @@ getaddrinfo(const char FAR * nodename, { pent = getprotobynumber(hints->ai_protocol); if (pent == NULL) - return WSAEINVAL; + { + error = WSAEINVAL; + goto End; + } proto = pent->p_name; } else proto = NULL; se = getservbyname(servname, proto); if (se == NULL) - return WSATYPE_NOT_FOUND; + { + error = WSATYPE_NOT_FOUND; + goto End; + } port = se->s_port; } else @@ -1639,7 +1655,10 @@ getaddrinfo(const char FAR * nodename, { /* Is it an IPv6 address? */ if (strstr(nodename, ":")) - return WSAHOST_NOT_FOUND; + { + error = WSAHOST_NOT_FOUND; + goto End; + } /* Is it an IPv4 address? */ addr = inet_addr(nodename); @@ -1729,16 +1748,24 @@ getaddrinfo(const char FAR * nodename, } if (ret == NULL) - return WSAHOST_NOT_FOUND; + { + error = WSAHOST_NOT_FOUND; + goto End; + } if (hints && hints->ai_family != PF_UNSPEC && hints->ai_family != PF_INET) { freeaddrinfo(ret); - return WSAEAFNOSUPPORT; + error = WSAEAFNOSUPPORT; + goto End; } *res = ret; - return 0; + error = 0; + +End: + WSASetLastError(error); + return error; } /* EOF */