Module: wine Branch: master Commit: 97645d7a1a9eec6100c637534620ac6811622794 URL: http://source.winehq.org/git/wine.git/?a=commit;h=97645d7a1a9eec6100c6375346...
Author: Ken Thomases ken@codeweavers.com Date: Mon Mar 12 22:50:09 2012 -0500
ntdll: Fix status returned for too-long registry value names.
---
dlls/ntdll/reg.c | 6 +++--- dlls/ntdll/tests/reg.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index d68f154..cdca88a 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -190,7 +190,7 @@ NTSTATUS WINAPI NtDeleteValueKey( HANDLE hkey, const UNICODE_STRING *name ) NTSTATUS ret;
TRACE( "(%p,%s)\n", hkey, debugstr_us(name) ); - if (name->Length > MAX_VALUE_LENGTH) return STATUS_BUFFER_OVERFLOW; + if (name->Length > MAX_VALUE_LENGTH) return STATUS_OBJECT_NAME_NOT_FOUND;
SERVER_START_REQ( delete_key_value ) { @@ -483,7 +483,7 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name,
TRACE( "(%p,%s,%d,%p,%d)\n", handle, debugstr_us(name), info_class, info, length );
- if (name->Length > MAX_VALUE_LENGTH) return STATUS_BUFFER_OVERFLOW; + if (name->Length > MAX_VALUE_LENGTH) return STATUS_OBJECT_NAME_NOT_FOUND;
/* compute the length we want to retrieve */ switch(info_class) @@ -771,7 +771,7 @@ NTSTATUS WINAPI NtSetValueKey( HANDLE hkey, const UNICODE_STRING *name, ULONG Ti
TRACE( "(%p,%s,%d,%p,%d)\n", hkey, debugstr_us(name), type, data, count );
- if (name->Length > MAX_VALUE_LENGTH) return STATUS_BUFFER_OVERFLOW; + if (name->Length > MAX_VALUE_LENGTH) return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( set_key_value ) { diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c index 1bd0a01..d56d4f8 100644 --- a/dlls/ntdll/tests/reg.c +++ b/dlls/ntdll/tests/reg.c @@ -1244,6 +1244,41 @@ static void test_redirection(void) pNtClose( key64 ); }
+static void test_long_value_name(void) +{ + HANDLE key; + NTSTATUS status, expected; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING ValName; + DWORD i; + + InitializeObjectAttributes(&attr, &winetestpath, 0, 0, 0); + status = pNtOpenKey(&key, KEY_WRITE|KEY_READ, &attr); + ok(status == STATUS_SUCCESS, "NtOpenKey Failed: 0x%08x\n", status); + + ValName.MaximumLength = 0xfffc; + ValName.Length = ValName.MaximumLength - sizeof(WCHAR); + ValName.Buffer = HeapAlloc(GetProcessHeap(), 0, ValName.MaximumLength); + for (i = 0; i < ValName.Length / sizeof(WCHAR); i++) + ValName.Buffer[i] = 'a'; + ValName.Buffer[i] = 0; + + status = pNtDeleteValueKey(key, &ValName); + ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "NtDeleteValueKey with nonexistent long value name returned 0x%08x\n", status); + status = pNtSetValueKey(key, &ValName, 0, REG_DWORD, &i, sizeof(i)); + ok(status == STATUS_INVALID_PARAMETER || broken(status == STATUS_SUCCESS) /* nt4 */, + "NtSetValueKey with long value name returned 0x%08x\n", status); + expected = (status == STATUS_SUCCESS) ? STATUS_SUCCESS : STATUS_OBJECT_NAME_NOT_FOUND; + status = pNtDeleteValueKey(key, &ValName); + ok(status == expected, "NtDeleteValueKey with long value name returned 0x%08x\n", status); + + status = pNtQueryValueKey(key, &ValName, KeyValueBasicInformation, NULL, 0, &i); + ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "NtQueryValueKey with nonexistent long value name returned 0x%08x\n", status); + + pRtlFreeUnicodeString(&ValName); + pNtClose(key); +} + START_TEST(reg) { static const WCHAR winetest[] = {'\','W','i','n','e','T','e','s','t',0}; @@ -1265,6 +1300,7 @@ START_TEST(reg) test_RtlpNtQueryValueKey(); test_NtFlushKey(); test_NtQueryValueKey(); + test_long_value_name(); test_NtDeleteKey(); test_symlinks(); test_redirection();