advapi32: Fix handling of zero account and domain size parameters in LookupAccountSid.
This commit is contained in:
parent
02bdbbc475
commit
0cffcb77d6
|
@ -2069,6 +2069,11 @@ LookupAccountSidA(
|
||||||
} else
|
} else
|
||||||
*domainSize = domainSizeW + 1;
|
*domainSize = domainSizeW + 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*accountSize = accountSizeW + 1;
|
||||||
|
*domainSize = domainSizeW + 1;
|
||||||
|
}
|
||||||
|
|
||||||
HeapFree( GetProcessHeap(), 0, systemW );
|
HeapFree( GetProcessHeap(), 0, systemW );
|
||||||
HeapFree( GetProcessHeap(), 0, accountW );
|
HeapFree( GetProcessHeap(), 0, accountW );
|
||||||
|
@ -2225,8 +2230,11 @@ LookupAccountSidW(
|
||||||
if (domain)
|
if (domain)
|
||||||
lstrcpyW(domain, dm);
|
lstrcpyW(domain, dm);
|
||||||
}
|
}
|
||||||
if (((*accountSize != 0) && (*accountSize < ac_len)) ||
|
if ((*accountSize && *accountSize < ac_len) ||
|
||||||
((*domainSize != 0) && (*domainSize < dm_len))) {
|
(!account && !*accountSize && ac_len) ||
|
||||||
|
(*domainSize && *domainSize < dm_len) ||
|
||||||
|
(!domain && !*domainSize && dm_len))
|
||||||
|
{
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
status = FALSE;
|
status = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2238,9 +2246,10 @@ LookupAccountSidW(
|
||||||
*accountSize = ac_len;
|
*accountSize = ac_len;
|
||||||
else
|
else
|
||||||
*accountSize = ac_len + 1;
|
*accountSize = ac_len + 1;
|
||||||
*name_use = use;
|
|
||||||
HeapFree(GetProcessHeap(), 0, account_name);
|
HeapFree(GetProcessHeap(), 0, account_name);
|
||||||
HeapFree(GetProcessHeap(), 0, computer_name);
|
HeapFree(GetProcessHeap(), 0, computer_name);
|
||||||
|
if (status) *name_use = use;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1505,7 +1505,7 @@ static void test_LookupAccountSid(void)
|
||||||
PSID pUsersSid = NULL;
|
PSID pUsersSid = NULL;
|
||||||
SID_NAME_USE use;
|
SID_NAME_USE use;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
DWORD size,cbti = 0;
|
DWORD error, size, cbti = 0;
|
||||||
MAX_SID max_sid;
|
MAX_SID max_sid;
|
||||||
CHAR *str_sidA;
|
CHAR *str_sidA;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1667,6 +1667,16 @@ static void test_LookupAccountSid(void)
|
||||||
"LookupAccountSidW() Expected dom_size = %u, got %u\n",
|
"LookupAccountSidW() Expected dom_size = %u, got %u\n",
|
||||||
real_dom_sizeW + 1, dom_sizeW);
|
real_dom_sizeW + 1, dom_sizeW);
|
||||||
|
|
||||||
|
acc_sizeW = dom_sizeW = use = 0;
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = LookupAccountSidW(NULL, pUsersSid, NULL, &acc_sizeW, NULL, &dom_sizeW, &use);
|
||||||
|
error = GetLastError();
|
||||||
|
ok(!ret, "LookupAccountSidW failed %u\n", GetLastError());
|
||||||
|
ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
|
||||||
|
ok(acc_sizeW, "expected non-zero account size\n");
|
||||||
|
ok(dom_sizeW, "expected non-zero domain size\n");
|
||||||
|
ok(!use, "expected zero use %u\n", use);
|
||||||
|
|
||||||
FreeSid(pUsersSid);
|
FreeSid(pUsersSid);
|
||||||
|
|
||||||
/* Test LookupAccountSid with Sid retrieved from token information.
|
/* Test LookupAccountSid with Sid retrieved from token information.
|
||||||
|
|
Loading…
Reference in New Issue