Replaced getlogin with getlogin_r

(cherry picked from commit 36478d3d0b)
This commit is contained in:
akallabeth 2020-05-25 14:01:23 +02:00 committed by Armin Novak
parent 8c3f6d2b19
commit 3606dfa921
3 changed files with 11 additions and 7 deletions

View File

@ -598,7 +598,10 @@ static BOOL isAutomountLocation(const char* path)
size_t x;
char buffer[MAX_PATH];
uid_t uid = getuid();
const char* uname = getlogin();
const char uname[MAX_PATH] = { 0 };
if (getlogin_r(uname, sizeof(uname)) != 0)
return FALSE;
if (!path)
return FALSE;

View File

@ -1181,9 +1181,9 @@ static BOOL xf_pre_connect(freerdp* instance)
if (!settings->Username && !settings->CredentialsFromStdin && !settings->SmartcardLogon)
{
char* login_name = getlogin();
char login_name[MAX_PATH] = { 0 };
if (login_name)
if (getlogin_r(login_name, sizeof(login_name)) == 0)
{
settings->Username = _strdup(login_name);

View File

@ -201,18 +201,19 @@ BOOL LogonUserExW(LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword
BOOL GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG nSize)
{
size_t length;
char* login;
char login[MAX_PATH];
switch (NameFormat)
{
case NameSamCompatible:
login = getlogin();
if (getlogin_r(login, sizeof(login)) != 0)
return FALSE;
length = strlen(login);
if (*nSize >= length)
{
CopyMemory(lpNameBuffer, login, length + 1);
return 1;
return TRUE;
}
else
{
@ -235,7 +236,7 @@ BOOL GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG
break;
}
return 0;
return FALSE;
}
BOOL GetUserNameExW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)