- handle servname being NULL

- patch by Yuri Sidorov <jura at cp-lab dot com>
See issue #3627 for more details.

svn path=/trunk/; revision=35111
This commit is contained in:
Ged Murphy 2008-08-04 17:26:03 +00:00
parent f143cab0bb
commit 40d661edfb

View file

@ -1407,6 +1407,8 @@ getaddrinfo(const char FAR * nodename,
if (!WSAINITIALIZED) if (!WSAINITIALIZED)
return WSANOTINITIALISED; return WSANOTINITIALISED;
if (servname)
{
/* converting port number */ /* converting port number */
port = strtoul(servname, NULL, 10); port = strtoul(servname, NULL, 10);
/* service name was specified? */ /* service name was specified? */
@ -1424,11 +1426,14 @@ getaddrinfo(const char FAR * nodename,
proto = NULL; proto = NULL;
se = getservbyname(servname, proto); se = getservbyname(servname, proto);
if (se == NULL) if (se == NULL)
return WSAHOST_NOT_FOUND; return WSATYPE_NOT_FOUND;
port = se->s_port; port = se->s_port;
} }
else else
port = htons(port); port = htons(port);
}
else
port = 0;
if (nodename) if (nodename)
{ {