Merge pull request #2613 from oshogbo/gethostname

At least at FreeBSD - the gethostname(3) function can fail.
This commit is contained in:
Hardening 2015-05-12 16:18:08 +02:00
commit 75634d460f
1 changed files with 5 additions and 2 deletions

View File

@ -179,7 +179,9 @@ BOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
char* dot;
int length;
char hostname[256];
gethostname(hostname, sizeof(hostname));
if (gethostname(hostname, sizeof(hostname)) == -1)
return FALSE;
length = strlen(hostname);
dot = strchr(hostname, '.');
@ -208,7 +210,8 @@ BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPSTR lpBuffer, LPDWORD l
if ((NameType == ComputerNameNetBIOS) || (NameType == ComputerNamePhysicalNetBIOS))
return GetComputerNameA(lpBuffer, lpnSize);
gethostname(hostname, sizeof(hostname));
if (gethostname(hostname, sizeof(hostname)) == -1)
return FALSE;
length = strlen(hostname);
switch (NameType)