- Set last error inside getaddrinfo to properly mask some non-fatal errors generated by adns

svn path=/trunk/; revision=57107
This commit is contained in:
Cameron Gutman 2012-08-19 07:32:47 +00:00
parent ebb8b4350e
commit 0813b21bc8

View file

@ -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 */