Commit ce58c358 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

advapi32: Add tests for LookupAccountSid.

parent 8fb90dea
...@@ -1485,15 +1485,15 @@ LookupAccountSidA( ...@@ -1485,15 +1485,15 @@ LookupAccountSidA(
domain,domainSize,domainSize?*domainSize:0, domain,domainSize,domainSize?*domainSize:0,
name_use); name_use);
if (accountSize) *accountSize = strlen(ac)+1; *accountSize = strlen(ac)+1;
if (account && (*accountSize > strlen(ac))) if (account && (*accountSize > strlen(ac)))
strcpy(account, ac); strcpy(account, ac);
if (domainSize) *domainSize = strlen(dm)+1; *domainSize = strlen(dm)+1;
if (domain && (*domainSize > strlen(dm))) if (domain && (*domainSize > strlen(dm)))
strcpy(domain,dm); strcpy(domain,dm);
if (name_use) *name_use = SidTypeUser; *name_use = SidTypeUser;
return TRUE; return TRUE;
} }
...@@ -1527,15 +1527,15 @@ LookupAccountSidW( ...@@ -1527,15 +1527,15 @@ LookupAccountSidW(
domain,domainSize,domainSize?*domainSize:0, domain,domainSize,domainSize?*domainSize:0,
name_use); name_use);
if (accountSize) *accountSize = strlenW(ac)+1; *accountSize = strlenW(ac)+1;
if (account && (*accountSize > strlenW(ac))) if (account && (*accountSize > strlenW(ac)))
strcpyW(account, ac); strcpyW(account, ac);
if (domainSize) *domainSize = strlenW(dm)+1; *domainSize = strlenW(dm)+1;
if (domain && (*domainSize > strlenW(dm))) if (domain && (*domainSize > strlenW(dm)))
strcpyW(domain,dm); strcpyW(domain,dm);
if (name_use) *name_use = SidTypeUser; *name_use = SidTypeUser;
return TRUE; return TRUE;
} }
......
...@@ -772,6 +772,34 @@ static void test_token_attr(void) ...@@ -772,6 +772,34 @@ static void test_token_attr(void)
} }
} }
static void test_LookupAccountSid(void)
{
SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY };
char account[MAX_PATH], domain[MAX_PATH];
DWORD acc_size, dom_size;
PSID pUsersSid = NULL;
SID_NAME_USE use;
BOOL ret;
/* native windows crashes if account size, domain size, or name use is NULL */
ret = AllocateAndInitializeSid(&SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_USERS, 0, 0, 0, 0, 0, 0, &pUsersSid);
ok(ret, "AllocateAndInitializeSid failed with error %ld\n", GetLastError());
/* try NULL account */
acc_size = MAX_PATH;
dom_size = MAX_PATH;
ret = LookupAccountSid(NULL, pUsersSid, NULL, &acc_size, domain, &dom_size, &use);
ok(ret, "Expected TRUE, got FALSE\n");
/* try NULL domain */
acc_size = MAX_PATH;
dom_size = MAX_PATH;
ret = LookupAccountSid(NULL, pUsersSid, account, &acc_size, NULL, &dom_size, &use);
ok(ret, "Expected TRUE, got FALSE\n");
}
START_TEST(security) START_TEST(security)
{ {
init(); init();
...@@ -782,4 +810,5 @@ START_TEST(security) ...@@ -782,4 +810,5 @@ START_TEST(security)
test_FileSecurity(); test_FileSecurity();
test_AccessCheck(); test_AccessCheck();
test_token_attr(); test_token_attr();
test_LookupAccountSid();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment