crypt32: GetUserName sets last error to ERROR_INSUFFICIENT_BUFFER if the buffer is too small.

This commit is contained in:
Hans Leidekker 2011-06-01 14:47:43 +02:00 committed by Alexandre Julliard
parent c0b7345e38
commit 0875abcce0
1 changed files with 2 additions and 2 deletions

View File

@ -722,8 +722,8 @@ BOOL load_encryption_key(HCRYPTPROV hProv, DWORD key_len, const DATA_BLOB *salt,
/* This should be the "logon credentials" instead of username */
dwError=GetLastError();
dwUsernameLen = 0;
if (!GetUserNameA(NULL,&dwUsernameLen) &&
GetLastError()==ERROR_MORE_DATA && dwUsernameLen &&
if (!GetUserNameA(NULL, &dwUsernameLen) &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER && dwUsernameLen &&
(szUsername = CryptMemAlloc(dwUsernameLen)))
{
szUsername[0]='\0';