Author: gedmurphy
Date: Mon Aug 4 12:26:03 2008
New Revision: 35111
URL:
http://svn.reactos.org/svn/reactos?rev=35111&view=rev
Log:
- handle servname being NULL
- patch by Yuri Sidorov <jura at cp-lab dot com>
See issue #3627 for more details.
Modified:
trunk/reactos/dll/win32/ws2_32/misc/ns.c
Modified: trunk/reactos/dll/win32/ws2_32/misc/ns.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/misc/ns.c…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/misc/ns.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/misc/ns.c [iso-8859-1] Mon Aug 4 12:26:03 2008
@@ -1407,28 +1407,33 @@
if (!WSAINITIALIZED)
return WSANOTINITIALISED;
- /* converting port number */
- port = strtoul(servname, NULL, 10);
- /* service name was specified? */
- if (port == 0)
- {
- /* protocol was specified? */
- if (hints && hints->ai_protocol)
+ if (servname)
+ {
+ /* converting port number */
+ port = strtoul(servname, NULL, 10);
+ /* service name was specified? */
+ if (port == 0)
{
- pent = getprotobynumber(hints->ai_protocol);
- if (pent == NULL)
- return WSAEINVAL;
- proto = pent->p_name;
+ /* protocol was specified? */
+ if (hints && hints->ai_protocol)
+ {
+ 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
- proto = NULL;
- se = getservbyname(servname, proto);
- if (se == NULL)
- return WSAHOST_NOT_FOUND;
- port = se->s_port;
+ port = htons(port);
}
else
- port = htons(port);
+ port = 0;
if (nodename)
{