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@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-11-10 12:22:19 +01:00
parent df0c5d23ef
commit 5ac2f4b553
1 changed files with 6 additions and 6 deletions

View File

@ -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;