From dcc3424afb977e64a2b485d423268c2bec135781 Mon Sep 17 00:00:00 2001 From: hater <7element@mail.bg> Date: Mon, 9 Nov 2015 12:13:33 +0200 Subject: [PATCH] Fix addrinfo tests --- reactos/dll/win32/ws2_32_new/src/addrinfo.c | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/ws2_32_new/src/addrinfo.c b/reactos/dll/win32/ws2_32_new/src/addrinfo.c index 73ce896..ed437f7 100644 --- a/reactos/dll/win32/ws2_32_new/src/addrinfo.c +++ b/reactos/dll/win32/ws2_32_new/src/addrinfo.c @@ -457,6 +457,7 @@ GetAddrInfoW(IN PCWSTR pszNodeName, INT iSocketType = 0; INT iProtocol = 0; WORD wPort = 0; + DWORD dwPort = 0; DWORD dwAddress = 0; PSERVENT ptService = NULL; PCHAR pc = NULL; @@ -464,8 +465,8 @@ GetAddrInfoW(IN PCWSTR pszNodeName, WORD wTcpPort = 0; WORD wUdpPort = 0; WCHAR CanonicalName[0x42]; - CHAR AnsiServiceName[256]; - CHAR AnsiNodeName[256]; + CHAR AnsiServiceName[MAX_HOSTNAME_LEN]; + CHAR AnsiNodeName[MAX_HOSTNAME_LEN]; DPRINT("GetAddrInfoW: %S, %S, %p, %p\n", pszNodeName, pszServiceName, ptHints, pptResult); /* Assume error */ @@ -530,12 +531,13 @@ GetAddrInfoW(IN PCWSTR pszNodeName, pszServiceName, -1, AnsiServiceName, - 256, + sizeof(AnsiServiceName), NULL, 0); /* Get the port */ - wPort = (WORD)strtoul(AnsiServiceName, &pc, 10); + dwPort = strtoul(AnsiServiceName, &pc, 10); + wPort = (WORD)(dwPort & 0x0000ffff); /* Check if the port string is numeric */ if (*pc == '\0') @@ -544,12 +546,14 @@ GetAddrInfoW(IN PCWSTR pszNodeName, wPort = wTcpPort = wUdpPort = htons(wPort); /* Check if this is both TCP and UDP */ +#if 0 if (iSocketType == 0) { /* Set it to TCP for now, but remember to clone */ bClone = TRUE; iSocketType = SOCK_STREAM; } +#endif } else { @@ -576,7 +580,7 @@ GetAddrInfoW(IN PCWSTR pszNodeName, /* If we got 0, then fail */ if (wPort == 0) { - return iSocketType ? EAI_SERVICE : EAI_NONAME; + return /*iSocketType ?*/ EAI_SERVICE /*: EAI_NONAME*/; } /* Check if this was for both */ @@ -584,7 +588,7 @@ GetAddrInfoW(IN PCWSTR pszNodeName, { /* Do the TCP case right now */ iSocketType = (wTcpPort) ? SOCK_STREAM : SOCK_DGRAM; - bClone = (wTcpPort && wUdpPort); + //bClone = (wTcpPort && wUdpPort); } } } @@ -736,7 +740,7 @@ getaddrinfo(const char FAR *nodename, struct addrinfo FAR * FAR *res) { INT ErrorCode; - LPWSTR UnicodeNodeName; + LPWSTR UnicodeNodeName = NULL; LPWSTR UnicodeServName = NULL; DPRINT("getaddrinfo: %s, %s, %p, %p\n", nodename, servname, hints, res); @@ -747,12 +751,15 @@ getaddrinfo(const char FAR *nodename, *res = NULL; /* Convert the node name */ - UnicodeNodeName = UnicodeDupFromAnsi((LPSTR)nodename); - if (!UnicodeNodeName) + if (nodename) { - /* Prepare to fail */ - ErrorCode = GetLastError(); - goto Quickie; + UnicodeNodeName = UnicodeDupFromAnsi((LPSTR)nodename); + if (!UnicodeNodeName) + { + /* Prepare to fail */ + ErrorCode = GetLastError(); + goto Quickie; + } } /* Convert the servname too, if we have one */ -- 1.9.5.msysgit.0