Fix return of getlogin()

This commit is contained in:
akallabeth 2022-06-02 13:45:34 +02:00
parent 51f378308f
commit 1e779f92ec

View File

@ -221,7 +221,12 @@ BOOL GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG
if (getlogin_r(lpNameBuffer, *nSize) != 0)
return FALSE;
#else
strncpy(lpNameBuffer, getlogin(), *nSize);
{
const char* name = getlogin();
if (!name)
return FALSE;
strncpy(lpNameBuffer, name, strnlen(name, *nSize));
}
#endif
*nSize = strnlen(lpNameBuffer, *nSize);
return TRUE;