Commit 4e19373c authored by Torge Matthies's avatar Torge Matthies Committed by Alexandre Julliard

ntdll: Calculate buffer sizes from registry structs correctly.

parent cf7cb993
...@@ -93,7 +93,7 @@ NTSTATUS WINAPI RtlpNtEnumerateSubKey( HANDLE handle, UNICODE_STRING *out, ULONG ...@@ -93,7 +93,7 @@ NTSTATUS WINAPI RtlpNtEnumerateSubKey( HANDLE handle, UNICODE_STRING *out, ULONG
if (out->MaximumLength) if (out->MaximumLength)
{ {
dwLen = out->MaximumLength + sizeof(KEY_BASIC_INFORMATION); dwLen = out->MaximumLength + offsetof(KEY_BASIC_INFORMATION, Name);
info = RtlAllocateHeap( GetProcessHeap(), 0, dwLen ); info = RtlAllocateHeap( GetProcessHeap(), 0, dwLen );
if (!info) if (!info)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
...@@ -105,7 +105,7 @@ NTSTATUS WINAPI RtlpNtEnumerateSubKey( HANDLE handle, UNICODE_STRING *out, ULONG ...@@ -105,7 +105,7 @@ NTSTATUS WINAPI RtlpNtEnumerateSubKey( HANDLE handle, UNICODE_STRING *out, ULONG
} }
ret = NtEnumerateKey( handle, index, KeyBasicInformation, info, dwLen, &dwResultLen ); ret = NtEnumerateKey( handle, index, KeyBasicInformation, info, dwLen, &dwResultLen );
dwResultLen -= sizeof(KEY_BASIC_INFORMATION); dwResultLen -= offsetof(KEY_BASIC_INFORMATION, Name);
if (ret == STATUS_BUFFER_OVERFLOW) if (ret == STATUS_BUFFER_OVERFLOW)
out->Length = dwResultLen; out->Length = dwResultLen;
...@@ -138,7 +138,7 @@ NTSTATUS WINAPI RtlpNtQueryValueKey( HANDLE handle, ULONG *result_type, PBYTE de ...@@ -138,7 +138,7 @@ NTSTATUS WINAPI RtlpNtQueryValueKey( HANDLE handle, ULONG *result_type, PBYTE de
UNICODE_STRING name; UNICODE_STRING name;
NTSTATUS ret; NTSTATUS ret;
DWORD dwResultLen; DWORD dwResultLen;
DWORD dwLen = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + (result_len ? *result_len : 0); DWORD dwLen = offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data[result_len ? *result_len : 0]);
info = RtlAllocateHeap( GetProcessHeap(), 0, dwLen ); info = RtlAllocateHeap( GetProcessHeap(), 0, dwLen );
if (!info) if (!info)
......
...@@ -2095,7 +2095,7 @@ static BOOL reg_query_value( HKEY key, LPCWSTR name, DWORD type, void *data, DWO ...@@ -2095,7 +2095,7 @@ static BOOL reg_query_value( HKEY key, LPCWSTR name, DWORD type, void *data, DWO
UNICODE_STRING nameW; UNICODE_STRING nameW;
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buf; KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buf;
if (count > sizeof(buf) - sizeof(KEY_VALUE_PARTIAL_INFORMATION)) return FALSE; if (count > sizeof(buf) - offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data)) return FALSE;
nameW.Buffer = (WCHAR *)name; nameW.Buffer = (WCHAR *)name;
nameW.Length = wcslen( name ) * sizeof(WCHAR); nameW.Length = wcslen( name ) * sizeof(WCHAR);
......
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