Added patch to try harder to get the host name address in getaddrinfo().

This commit is contained in:
Sebastian Lackner 2014-12-23 07:12:43 +01:00
parent 91e07b125f
commit ce701fe0df
5 changed files with 185 additions and 1 deletions

View File

@ -37,7 +37,7 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
===================================
**Bugfixes and features included in the next upcoming release [10]:**
**Bugfixes and features included in the next upcoming release [11]:**
* Add stub for D3DXComputeTangentFrameEx ([Wine Bug #31984](https://bugs.winehq.org/show_bug.cgi?id=31984))
* Add stub for D3DXIntersect
@ -48,6 +48,7 @@ Included bug fixes and improvements
* Implement ID3DXEffect::FindNextValidTechnique ([Wine Bug #34101](https://bugs.winehq.org/show_bug.cgi?id=34101))
* Implement IDXGIOutput::GetDesc
* Support for SLGetWindowsInformationDWORD ([Wine Bug #36709](https://bugs.winehq.org/show_bug.cgi?id=36709))
* Try harder to get the host name address in getaddrinfo() ([Wine Bug #29609](https://bugs.winehq.org/show_bug.cgi?id=29609))
* Use actual program name if available to describe PulseAudio streams

1
debian/changelog vendored
View File

@ -16,6 +16,7 @@ wine-staging (1.7.34) UNRELEASED; urgency=low
* Added patch for support of SLGetWindowsInformationDWORD.
* Added patch to expect the correct buffer size for different IOCTL_DVD_READ_STRUCTURE requests.
* Added patch to use actual program name if available to describe PulseAudio streams.
* Added patch to try harder to get the host name address in getaddrinfo().
* Removed patch to implement combase HSTRING objects (accepted upstream).
* Removed patch to add fake ProductId to registry (accepted upstream).
* Removed patch to implement stubs for MFStartup and MFShutdown (accepted upstream).

View File

@ -142,6 +142,7 @@ PATCHLIST := \
ws2_32-Connect_Time.ok \
ws2_32-TransmitFile.ok \
ws2_32-WriteWatches.ok \
ws2_32-getaddrinfo.ok \
wtsapi32-EnumerateProcesses.ok
.PHONY: install
@ -2626,6 +2627,21 @@ ws2_32-WriteWatches.ok:
echo '+ { "Sebastian Lackner", "ws2_32: Avoid race-conditions of async WSARecv() operations with write watches.", 1 },'; \
) > ws2_32-WriteWatches.ok
# Patchset ws2_32-getaddrinfo
# |
# | This patchset fixes the following Wine bugs:
# | * [#29609] Try harder to get the host name address in getaddrinfo()
# |
# | Modified files:
# | * dlls/ws2_32/socket.c, dlls/ws2_32/tests/sock.c
# |
.INTERMEDIATE: ws2_32-getaddrinfo.ok
ws2_32-getaddrinfo.ok:
$(call APPLY_FILE,ws2_32-getaddrinfo/0001-ws2_32-Try-harder-to-get-the-host-name-address-in-ge.patch)
@( \
echo '+ { "Bruno Jesus", "ws2_32: Try harder to get the host name address in getaddrinfo().", 1 },'; \
) > ws2_32-getaddrinfo.ok
# Patchset wtsapi32-EnumerateProcesses
# |
# | This patchset fixes the following Wine bugs:

View File

@ -0,0 +1,165 @@
From aef4dcbdd1b94d187d21588d4d74385b7dd46c5f Mon Sep 17 00:00:00 2001
From: Bruno Jesus <00cpxxx@gmail.com>
Date: Sat, 13 Dec 2014 17:36:40 -0200
Subject: ws2_32: Try harder to get the host name address in getaddrinfo()
When the host name is not resolvable getaddrinfo/GetAddrInfoW will
fail, this is not expected for some applications like League of
Legends [1][2][3]. We can deal with this in two ways:
- Try harder and use a NULL name to resolve the localhost address
(user transparent).
- Just warn the user and give up (requires the user to understand the
issue and fix /etc/hosts).
This patch tries harder and at the same time warns the user.
Tested on PC-BSD 9 and Debian 7 by removing the host name in /etc/hosts.
Fixes bug https://bugs.winehq.org/show_bug.cgi?id=29609 for some people.
[1] https://bugs.winehq.org/show_bug.cgi?id=29609#c10
[2] https://bugs.winehq.org/show_bug.cgi?id=29609#c13
[3] http://www.playonlinux.com/fr/topic-10056-League_of_Legends_crash_after_champ_select.html
---
dlls/ws2_32/socket.c | 18 +++++++++++++-----
dlls/ws2_32/tests/sock.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index b6aad67..d5404b7 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -5621,19 +5621,19 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr
struct addrinfo *unixaires = NULL;
int result;
struct addrinfo unixhints, *punixhints = NULL;
- char *hostname = NULL;
+ char *hostname;
const char *node;
*res = NULL;
if (!nodename && !servname) return WSAHOST_NOT_FOUND;
+ hostname = get_hostname();
+ if (!hostname) return WSA_NOT_ENOUGH_MEMORY;
+
if (!nodename)
node = NULL;
else if (!nodename[0])
- {
- node = hostname = get_hostname();
- if (!node) return WSA_NOT_ENOUGH_MEMORY;
- }
+ node = hostname;
else
node = nodename;
@@ -5677,6 +5677,14 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr
/* getaddrinfo(3) is thread safe, no need to wrap in CS */
result = getaddrinfo(node, servname, punixhints, &unixaires);
+ if (result && !strcmp(hostname, node))
+ {
+ /* If it didn't work it means the host name IP is not in /etc/hosts, try again
+ * by sending a NULL host and avoid sending a NULL servname too because that
+ * is invalid */
+ ERR_(winediag)("Failed to resolve your host name IP, attempting to resolve as NULL. You should fix this!\n");
+ result = getaddrinfo(NULL, servname ? servname : "0", punixhints, &unixaires);
+ }
TRACE("%s, %s %p -> %p %d\n", debugstr_a(nodename), debugstr_a(servname), hints, res, result);
HeapFree(GetProcessHeap(), 0, hostname);
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 49ebbf5..c322e73 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -5802,12 +5802,17 @@ static void test_GetAddrInfoW(void)
static const WCHAR zero[] = {'0',0};
int i, ret;
ADDRINFOW *result, *result2, *p, hint;
+ char computernameA[256];
+ WCHAR computername[sizeof(computernameA)];
if (!pGetAddrInfoW || !pFreeAddrInfoW)
{
win_skip("GetAddrInfoW and/or FreeAddrInfoW not present\n");
return;
}
+ ret = gethostname(computernameA, sizeof(computernameA));
+ ok(!ret, "Expected gethostname to work\n");
+ MultiByteToWideChar(CP_ACP, 0, computernameA, -1, computername, sizeof(computernameA));
memset(&hint, 0, sizeof(ADDRINFOW));
result = (ADDRINFOW *)0xdeadbeef;
@@ -5867,6 +5872,25 @@ static void test_GetAddrInfoW(void)
ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
pFreeAddrInfoW(result);
+ ret = pGetAddrInfoW(computername, NULL, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ pFreeAddrInfoW(result);
+
+ result = NULL;
+ ret = pGetAddrInfoW(computername, empty, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ pFreeAddrInfoW(result);
+
+ result = NULL;
+ ret = pGetAddrInfoW(computername, zero, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ pFreeAddrInfoW(result);
+
+ result = NULL;
+ ret = pGetAddrInfoW(computername, port, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ pFreeAddrInfoW(result);
+
result = NULL;
ret = pGetAddrInfoW(localhost, NULL, &hint, &result);
ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
@@ -5953,12 +5977,15 @@ static void test_getaddrinfo(void)
{
int i, ret;
ADDRINFOA *result, *result2, *p, hint;
+ char computername[256];
if (!pgetaddrinfo || !pfreeaddrinfo)
{
win_skip("getaddrinfo and/or freeaddrinfo not present\n");
return;
}
+ ret = gethostname(computername, sizeof(computername));
+ ok(!ret, "Expected gethostname to work\n");
memset(&hint, 0, sizeof(ADDRINFOA));
result = (ADDRINFOA *)0xdeadbeef;
@@ -6019,6 +6046,26 @@ static void test_getaddrinfo(void)
pfreeaddrinfo(result);
result = NULL;
+ ret = pgetaddrinfo(computername, NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ pfreeaddrinfo(result);
+
+ result = NULL;
+ ret = pgetaddrinfo(computername, "", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ pfreeaddrinfo(result);
+
+ result = NULL;
+ ret = pgetaddrinfo(computername, "0", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ pfreeaddrinfo(result);
+
+ result = NULL;
+ ret = pgetaddrinfo(computername, "80", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ pfreeaddrinfo(result);
+
+ result = NULL;
ret = pgetaddrinfo("localhost", NULL, &hint, &result);
ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
pfreeaddrinfo(result);
--
2.2.1

View File

@ -0,0 +1 @@
Fixes: [29609] Try harder to get the host name address in getaddrinfo()