Skip to content

Commit 49fc956

Browse files
committed
Platform (Windows): improves hostname retrieval by adding fallback to NetBIOS name
1 parent 3d84ad1 commit 49fc956

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/common/impl/FFPlatform_windows.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,16 @@ static void getUserName(FFPlatform* platform)
155155

156156
static void getHostName(FFPlatform* platform)
157157
{
158-
wchar_t buffer[128];
158+
wchar_t buffer[256];
159159
DWORD len = ARRAY_SIZE(buffer);
160-
if(GetComputerNameExW(ComputerNameDnsHostname, buffer, &len))
161-
ffStrbufSetWS(&platform->hostName, buffer);
160+
if (GetComputerNameExW(ComputerNameDnsHostname, buffer, &len) && len > 0)
161+
ffStrbufSetNWS(&platform->hostName, len, buffer);
162+
else
163+
{
164+
len = ARRAY_SIZE(buffer);
165+
if (GetComputerNameExW(ComputerNameNetBIOS, buffer, &len) && len > 0)
166+
ffStrbufSetNWS(&platform->hostName, len, buffer);
167+
}
162168
}
163169

164170
static void getUserShell(FFPlatform* platform)

0 commit comments

Comments
 (0)