From e958a570e5f40f3d288bf1c0a4366c5c7bb90f1c Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Sun, 6 Jan 2008 15:35:56 +0000 Subject: [PATCH] ntdll: Fix the Data and Name returned by NtQueryValueKey for KeyValueFullInformation. --- dlls/ntdll/reg.c | 10 +++++++++- dlls/ntdll/tests/reg.c | 3 --- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index 7620bdd26e4..e2a3b918e14 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -485,9 +485,17 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name, data_ptr = NULL; break; case KeyValueFullInformation: - data_ptr = (UCHAR *)((KEY_VALUE_FULL_INFORMATION *)info)->Name; + { + KEY_VALUE_FULL_INFORMATION *full_info = info; + if (FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION, Name) < length) + { + memcpy(full_info->Name, name->Buffer, + min(length - FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION, Name), name->Length)); + } + data_ptr = (UCHAR *)full_info->Name + name->Length; fixed_size = (char *)data_ptr - (char *)info; break; + } case KeyValuePartialInformation: data_ptr = ((KEY_VALUE_PARTIAL_INFORMATION *)info)->Data; fixed_size = (char *)data_ptr - (char *)info; diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c index b5653d8d779..3b983ee096a 100644 --- a/dlls/ntdll/tests/reg.c +++ b/dlls/ntdll/tests/reg.c @@ -501,7 +501,6 @@ static void test_NtQueryValueKey(void) ok(full_info->Type == REG_DWORD, "NtQueryValueKey returned wrong Type %d\n", full_info->Type); ok(full_info->DataLength == 4, "NtQueryValueKey returned wrong DataLength %d\n", full_info->DataLength); ok(full_info->NameLength == 20, "NtQueryValueKey returned wrong NameLength %d\n", full_info->NameLength); - todo_wine ok(len == FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION, Name[0]) + full_info->DataLength + full_info->NameLength, "NtQueryValueKey returned wrong len %d\n", len); len = FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION, Name[0]) + full_info->DataLength + full_info->NameLength; @@ -513,9 +512,7 @@ static void test_NtQueryValueKey(void) ok(full_info->Type == REG_DWORD, "NtQueryValueKey returned wrong Type %d\n", full_info->Type); ok(full_info->DataLength == 4, "NtQueryValueKey returned wrong DataLength %d\n", full_info->DataLength); ok(full_info->NameLength == 20, "NtQueryValueKey returned wrong NameLength %d\n", full_info->NameLength); - todo_wine ok(!memcmp(full_info->Name, ValName.Buffer, ValName.Length), "incorrect Name returned\n"); - todo_wine ok(*(DWORD *)((char *)full_info + full_info->DataOffset) == 711, "incorrect Data returned: 0x%x\n", *(DWORD *)((char *)full_info + full_info->DataOffset)); HeapFree(GetProcessHeap(), 0, full_info);