[sysconf] _SC_GETPW_R_SIZE_MAX return checks
fix possible overflow with value returned from sysconf(_SC_GETPW_R_SIZE_MAX)
This commit is contained in:
parent
ae5f655f12
commit
a84b303c23
@ -59,11 +59,11 @@ BOOL GetUserProfileDirectoryA(HANDLE hToken, LPSTR lpProfileDir, LPDWORD lpcchSi
|
||||
}
|
||||
|
||||
long buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
|
||||
if (buflen == -1)
|
||||
if (buflen < 0)
|
||||
buflen = 8196;
|
||||
|
||||
char* buf = (char*)malloc(buflen);
|
||||
const size_t s = 1ULL + (size_t)buflen;
|
||||
char* buf = calloc(s, sizeof(char));
|
||||
|
||||
if (!buf)
|
||||
return FALSE;
|
||||
|
@ -153,10 +153,11 @@ BOOL LogonUserA(LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword, DWO
|
||||
}
|
||||
|
||||
long buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
if (buflen == -1)
|
||||
if (buflen < 0)
|
||||
buflen = 8196;
|
||||
|
||||
char* buf = (char*)calloc(buflen + 1, sizeof(char));
|
||||
const size_t s = 1ULL + (size_t)buflen;
|
||||
char* buf = (char*)calloc(s, sizeof(char));
|
||||
if (!buf)
|
||||
goto fail;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user