Commit 02ad0928 authored by Owen Rudge's avatar Owen Rudge Committed by Alexandre Julliard

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

parent a2ff4f37
...@@ -514,14 +514,15 @@ NTSTATUS WINAPI LsaLookupSids( ...@@ -514,14 +514,15 @@ NTSTATUS WINAPI LsaLookupSids(
{ {
(*Names)[i].Name.Length = (name_size - 1) * sizeof(WCHAR); (*Names)[i].Name.Length = (name_size - 1) * sizeof(WCHAR);
(*Names)[i].Name.MaximumLength = name_size * sizeof(WCHAR); (*Names)[i].Name.MaximumLength = name_size * sizeof(WCHAR);
name_fullsize += (*Names)[i].Name.MaximumLength;
} }
else else
{ {
(*Names)[i].Name.Length = 0; (*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. /* 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. */ Also it's not possible to store domain name length right here for the same reason. */
if (domain_size) if (domain_size)
...@@ -546,6 +547,13 @@ NTSTATUS WINAPI LsaLookupSids( ...@@ -546,6 +547,13 @@ NTSTATUS WINAPI LsaLookupSids(
heap_free(name); 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( ...@@ -572,18 +580,22 @@ NTSTATUS WINAPI LsaLookupSids(
{ {
domain.Length = (domain_size - 1) * sizeof(WCHAR); domain.Length = (domain_size - 1) * sizeof(WCHAR);
domain.MaximumLength = domain_size * 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; (*Names)[i].Name.Buffer = name_buffer;
LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use); LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use);
(*Names)[i].Use = 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; name_buffer += name_size;
......
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