From 40d661edfb8a9d875b28eb0f5f85fd00f9cc4380 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Mon, 4 Aug 2008 17:26:03 +0000 Subject: [PATCH] - handle servname being NULL - patch by Yuri Sidorov See issue #3627 for more details. svn path=/trunk/; revision=35111 --- reactos/dll/win32/ws2_32/misc/ns.c | 37 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/reactos/dll/win32/ws2_32/misc/ns.c b/reactos/dll/win32/ws2_32/misc/ns.c index bf2cda5a8b2..1db254dee9b 100644 --- a/reactos/dll/win32/ws2_32/misc/ns.c +++ b/reactos/dll/win32/ws2_32/misc/ns.c @@ -1407,28 +1407,33 @@ getaddrinfo(const char FAR * nodename, if (!WSAINITIALIZED) return WSANOTINITIALISED; - /* converting port number */ - port = strtoul(servname, NULL, 10); - /* service name was specified? */ - if (port == 0) + if (servname) { - /* protocol was specified? */ - if (hints && hints->ai_protocol) + /* 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) {