Alexandre Julliard : wineboot: Fall back to initial hostname if the name lookup fails.

Alexandre Julliard julliard at winehq.org
Tue Nov 10 15:30:23 CST 2020


Module: wine
Branch: master
Commit: 5ac2f4b55338a27c5d8c7e891bc29198dee7ea50
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5ac2f4b55338a27c5d8c7e891bc29198dee7ea50

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Nov 10 12:22:19 2020 +0100

wineboot: Fall back to initial hostname if the name lookup fails.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50084
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/wineboot/wineboot.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index fa1c459035f..05a5ee6aa62 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -820,18 +820,18 @@ static void create_environment_registry_keys( void )
 static void create_computer_name_keys(void)
 {
     struct addrinfo hints = {0}, *res;
-    char *dot, buffer[256];
+    char *dot, buffer[256], *name = buffer;
     HKEY key, subkey;
 
     if (gethostname( buffer, sizeof(buffer) )) return;
     hints.ai_flags = AI_CANONNAME;
-    if (getaddrinfo( buffer, NULL, &hints, &res )) return;
-    dot = strchr( res->ai_canonname, '.' );
+    if (!getaddrinfo( buffer, NULL, &hints, &res )) name = res->ai_canonname;
+    dot = strchr( name, '.' );
     if (dot) *dot++ = 0;
-    else dot = res->ai_canonname + strlen(res->ai_canonname);
+    else dot = name + strlen(name);
     SetComputerNameExA( ComputerNamePhysicalDnsDomain, dot );
-    SetComputerNameExA( ComputerNamePhysicalDnsHostname, res->ai_canonname );
-    freeaddrinfo( res );
+    SetComputerNameExA( ComputerNamePhysicalDnsHostname, name );
+    if (name != buffer) freeaddrinfo( res );
 
     if (RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\ComputerName", &key ))
         return;




More information about the wine-cvs mailing list