ntdll: Fix status returned for too-long registry value names.
This commit is contained in:
parent
7fd6ccd19e
commit
97645d7a1a
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue