mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 18:02:05 +00:00
- 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:
parent
f143cab0bb
commit
40d661edfb
1 changed files with 21 additions and 16 deletions
|
@ -1407,28 +1407,33 @@ getaddrinfo(const char FAR * nodename,
|
||||||
if (!WSAINITIALIZED)
|
if (!WSAINITIALIZED)
|
||||||
return WSANOTINITIALISED;
|
return WSANOTINITIALISED;
|
||||||
|
|
||||||
/* converting port number */
|
if (servname)
|
||||||
port = strtoul(servname, NULL, 10);
|
|
||||||
/* service name was specified? */
|
|
||||||
if (port == 0)
|
|
||||||
{
|
{
|
||||||
/* protocol was specified? */
|
/* converting port number */
|
||||||
if (hints && hints->ai_protocol)
|
port = strtoul(servname, NULL, 10);
|
||||||
|
/* service name was specified? */
|
||||||
|
if (port == 0)
|
||||||
{
|
{
|
||||||
pent = getprotobynumber(hints->ai_protocol);
|
/* protocol was specified? */
|
||||||
if (pent == NULL)
|
if (hints && hints->ai_protocol)
|
||||||
return WSAEINVAL;
|
{
|
||||||
proto = pent->p_name;
|
pent = getprotobynumber(hints->ai_protocol);
|
||||||
|
if (pent == NULL)
|
||||||
|
return WSAEINVAL;
|
||||||
|
proto = pent->p_name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
proto = NULL;
|
||||||
|
se = getservbyname(servname, proto);
|
||||||
|
if (se == NULL)
|
||||||
|
return WSATYPE_NOT_FOUND;
|
||||||
|
port = se->s_port;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
proto = NULL;
|
port = htons(port);
|
||||||
se = getservbyname(servname, proto);
|
|
||||||
if (se == NULL)
|
|
||||||
return WSAHOST_NOT_FOUND;
|
|
||||||
port = se->s_port;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
port = htons(port);
|
port = 0;
|
||||||
|
|
||||||
if (nodename)
|
if (nodename)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue