From: Damjan Jovanovic Subject: [PATCH] ws2_32: deal with getaddrinfo() returning NULL ai_canonname despite AI_CANONNAME Message-Id: Date: Sun, 27 Dec 2020 11:39:18 +0200 This fixes a wineboot crash on FreeBSD, where getaddrinfo() returns a NULL ai_canonname, causing wineboot to pass NULL to strchr(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50408 Signed-off-by: Damjan Jovanovic --- dlls/ws2_32/socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 05097ce53b8..c1e71112993 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -6616,6 +6616,12 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr * is invalid */ ERR_(winediag)("Failed to resolve your host name IP\n"); result = getaddrinfo(NULL, servname ? servname : "0", punixhints, &unixaires); + /* Sometimes getaddrinfo() doesn't honor AI_CANONNAME and returns a NULL ai_canonname */ + if (!result && punixhints && (punixhints->ai_flags & AI_CANONNAME) && unixaires && !unixaires->ai_canonname) + { + freeaddrinfo(unixaires); + result = EAI_NONAME; + } } } TRACE("%s, %s %p -> %p %d\n", debugstr_a(nodename), debugstr_a(servname), hints, res, result);