Commit b60a2710 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

advapi32: Use heap helpers in security code.

parent 334eedb0
...@@ -78,7 +78,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs) ...@@ -78,7 +78,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size); ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS) if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
{ {
ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz + size); ptr = heap_alloc_zero(sz + size);
if (!ptr) return NULL; if (!ptr) return NULL;
ustr = (UNICODE_STRING*)(ptr + ofs); ustr = (UNICODE_STRING*)(ptr + ofs);
ustr->MaximumLength = size; ustr->MaximumLength = size;
...@@ -86,7 +86,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs) ...@@ -86,7 +86,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ret = RegQueryValueExW(key, wg, NULL, NULL, (LPBYTE)ustr->Buffer, &size); ret = RegQueryValueExW(key, wg, NULL, NULL, (LPBYTE)ustr->Buffer, &size);
if (ret != ERROR_SUCCESS) if (ret != ERROR_SUCCESS)
{ {
HeapFree(GetProcessHeap(), 0, ptr); heap_free(ptr);
ptr = NULL; ptr = NULL;
} }
else ustr->Length = size - sizeof(WCHAR); else ustr->Length = size - sizeof(WCHAR);
...@@ -96,8 +96,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs) ...@@ -96,8 +96,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
if (!ptr) if (!ptr)
{ {
static const WCHAR wDomain[] = {'D','O','M','A','I','N','\0'}; static const WCHAR wDomain[] = {'D','O','M','A','I','N','\0'};
ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ptr = heap_alloc_zero(sz + sizeof(wDomain));
sz + sizeof(wDomain));
if (!ptr) return NULL; if (!ptr) return NULL;
ustr = (UNICODE_STRING*)(ptr + ofs); ustr = (UNICODE_STRING*)(ptr + ofs);
ustr->MaximumLength = sizeof(wDomain); ustr->MaximumLength = sizeof(wDomain);
...@@ -265,7 +264,7 @@ NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer) ...@@ -265,7 +264,7 @@ NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
{ {
TRACE("(%p)\n", Buffer); TRACE("(%p)\n", Buffer);
HeapFree(GetProcessHeap(), 0, Buffer); heap_free(Buffer);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -689,8 +688,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy( ...@@ -689,8 +688,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
{ {
case PolicyAuditEventsInformation: /* 2 */ case PolicyAuditEventsInformation: /* 2 */
{ {
PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, PPOLICY_AUDIT_EVENTS_INFO p = heap_alloc_zero(sizeof(POLICY_AUDIT_EVENTS_INFO));
sizeof(POLICY_AUDIT_EVENTS_INFO));
p->AuditingMode = FALSE; /* no auditing */ p->AuditingMode = FALSE; /* no auditing */
*Buffer = p; *Buffer = p;
} }
...@@ -720,7 +718,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy( ...@@ -720,7 +718,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
}; };
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*xdi)); struct di * xdi = heap_alloc_zero(sizeof(*xdi));
xdi->info.DomainName.MaximumLength = dwSize * sizeof(WCHAR); xdi->info.DomainName.MaximumLength = dwSize * sizeof(WCHAR);
xdi->info.DomainName.Buffer = xdi->domain; xdi->info.DomainName.Buffer = xdi->domain;
...@@ -733,7 +731,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy( ...@@ -733,7 +731,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
if (!ADVAPI_GetComputerSid(&xdi->sid)) if (!ADVAPI_GetComputerSid(&xdi->sid))
{ {
HeapFree(GetProcessHeap(), 0, xdi); heap_free(xdi);
WARN("Computer SID not found\n"); WARN("Computer SID not found\n");
......
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