advapi32: Return null-terminated buffer instead of null pointer for LsaLookupSids domains.

Signed-off-by: Owen Rudge <orudge@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Owen Rudge 2017-02-02 10:30:44 +00:00 committed by Alexandre Julliard
parent a2ff4f37fd
commit 02ad092868
1 changed files with 20 additions and 8 deletions

View File

@ -514,14 +514,15 @@ NTSTATUS WINAPI LsaLookupSids(
{
(*Names)[i].Name.Length = (name_size - 1) * sizeof(WCHAR);
(*Names)[i].Name.MaximumLength = name_size * sizeof(WCHAR);
name_fullsize += (*Names)[i].Name.MaximumLength;
}
else
{
(*Names)[i].Name.Length = 0;
(*Names)[i].Name.MaximumLength = 0;
(*Names)[i].Name.MaximumLength = sizeof(WCHAR);
}
name_fullsize += (*Names)[i].Name.MaximumLength;
/* This potentially allocates more than needed, cause different names will reuse same domain index.
Also it's not possible to store domain name length right here for the same reason. */
if (domain_size)
@ -546,6 +547,13 @@ NTSTATUS WINAPI LsaLookupSids(
heap_free(name);
}
else
{
/* If we don't have a domain name, use a zero-length entry rather than a null value. */
domain_fullsize += sizeof(WCHAR);
domain.Length = 0;
domain.MaximumLength = sizeof(WCHAR);
}
}
}
@ -572,18 +580,22 @@ NTSTATUS WINAPI LsaLookupSids(
{
domain.Length = (domain_size - 1) * sizeof(WCHAR);
domain.MaximumLength = domain_size * sizeof(WCHAR);
domain.Buffer = heap_alloc(domain.MaximumLength);
}
else
{
/* Use a zero-length buffer */
domain.Length = 0;
domain.MaximumLength = sizeof(WCHAR);
}
domain.Buffer = heap_alloc(domain.MaximumLength);
(*Names)[i].Name.Buffer = name_buffer;
LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use);
(*Names)[i].Use = use;
if (domain_size)
{
(*Names)[i].DomainIndex = lsa_reflist_add_domain(*ReferencedDomains, &domain, &domain_data);
heap_free(domain.Buffer);
}
(*Names)[i].DomainIndex = lsa_reflist_add_domain(*ReferencedDomains, &domain, &domain_data);
heap_free(domain.Buffer);
}
name_buffer += name_size;