[PATCH 0/1] MR9938: wineboot: Check if ai_canonname is NULL.
Linux may not ever return a null cannonname when AI_CANONNAME is set, but macOS does. Fixes: 88854b52599d76b9fdd51819396aacf009712655 --- Looks like macOS isn't POSIX-compliant in this case, and in certain setups will return a NULL. Jinoh I just assigned you since you looked over !8918; feel free to unassign yourself if you don't have any feelings. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9938
From: Tim Clem <tclem@codeweavers.com> Linux may not ever return a null cannonname when AI_CANONNAME is set, but macOS does. Fixes: 88854b52599d76b9fdd51819396aacf009712655 --- programs/wineboot/wineboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 1e2a7b7b4c4..e8bbdcf59a3 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -836,7 +836,7 @@ static void create_computer_name_keys(void) hints.ai_flags = AI_CANONNAME; if (getaddrinfo( buffer, NULL, &hints, &res ) != 0) res = NULL; - else if (strcasecmp( res->ai_canonname, "localhost" ) != 0) + else if (res->ai_canonname && strcasecmp( res->ai_canonname, "localhost" ) != 0) name = res->ai_canonname; dot = strchr( name, '.' ); if (dot) *dot++ = 0; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9938
What about Windows, though? Can we test Windows in analogous setups? If Windows never returns NULL then we should probably follow that, and work around it in ws2_32. FWIW, MSDN does say this: "The getaddrinfo function can return success when the AI_CANONNAME flag is set, yet the ai_canonname member in the associated addrinfo structure is NULL. Therefore, the recommended use of the AI_CANONNAME flag includes testing whether the ai_canonname member in the associated addrinfo structure is NULL." But we all know how much to trust MSDN. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9938#note_127443
On Tue Jan 20 20:16:51 2026 +0000, Elizabeth Figura wrote:
What about Windows, though? Can we test Windows in analogous setups? If Windows never returns NULL then we should probably follow that, and work around it in ws2_32. FWIW, MSDN does say this: "The getaddrinfo function can return success when the AI_CANONNAME flag is set, yet the ai_canonname member in the associated addrinfo structure is NULL. Therefore, the recommended use of the AI_CANONNAME flag includes testing whether the ai_canonname member in the associated addrinfo structure is NULL." But we all know how much to trust MSDN. Oh hm, yes, that's a good point. I guess my thought was to fix the regression first and then consider the bigger picture.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9938#note_127444
This merge request was approved by Jinoh Kang. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9938
On Tue Jan 20 21:21:07 2026 +0000, Tim Clem wrote:
Oh hm, yes, that's a good point. I guess my thought was to fix the regression first and then consider the bigger picture. I'm not sure how we'd coerce Windows into doing returning a NULL canon name. I'm not even entirely sure how this happens on macOS - we are just getting reports that point to the `strcasecmp` failing with a NULL argument. It seems to arise from using `scutil --set HostName`, which results in `gethostname` returning something that doesn't quite resolve (or at least doesn't have a canon name). Hmm, okay. I don't know how else ai_canonname would ever be NULL on Windows, but the documentation does call it out. I suppose there's no reason to reject this patch, at least.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9938#note_127698
participants (4)
-
Elizabeth Figura (@zfigura) -
Jinoh Kang (@iamahuman) -
Tim Clem -
Tim Clem (@tclem)