Commit 0e98500e authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Fix the return value of NtOpenKey for some invalid parameters.

parent 2530304f
...@@ -311,6 +311,7 @@ LSTATUS WINAPI RegOpenKeyExW( HKEY hkey, LPCWSTR name, DWORD options, REGSAM acc ...@@ -311,6 +311,7 @@ LSTATUS WINAPI RegOpenKeyExW( HKEY hkey, LPCWSTR name, DWORD options, REGSAM acc
/* NT+ allows beginning backslash for HKEY_CLASSES_ROOT */ /* NT+ allows beginning backslash for HKEY_CLASSES_ROOT */
if (hkey == HKEY_CLASSES_ROOT && name && *name == '\\') name++; if (hkey == HKEY_CLASSES_ROOT && name && *name == '\\') name++;
if (!retkey) return ERROR_INVALID_PARAMETER;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE; if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
......
...@@ -116,13 +116,13 @@ NTSTATUS WINAPI NtOpenKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTR ...@@ -116,13 +116,13 @@ NTSTATUS WINAPI NtOpenKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTR
NTSTATUS ret; NTSTATUS ret;
DWORD len; DWORD len;
if (!attr) return STATUS_ACCESS_VIOLATION; if (!retkey || !attr) return STATUS_ACCESS_VIOLATION;
if (attr->Length > sizeof(OBJECT_ATTRIBUTES)) return STATUS_INVALID_PARAMETER;
len = attr->ObjectName->Length; len = attr->ObjectName->Length;
TRACE( "(%p,%s,%x,%p)\n", attr->RootDirectory, TRACE( "(%p,%s,%x,%p)\n", attr->RootDirectory,
debugstr_us(attr->ObjectName), access, retkey ); debugstr_us(attr->ObjectName), access, retkey );
if (len > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW; if (len > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
if (!retkey) return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( open_key ) SERVER_START_REQ( open_key )
{ {
......
...@@ -351,14 +351,12 @@ static void test_NtOpenKey(void) ...@@ -351,14 +351,12 @@ static void test_NtOpenKey(void)
/* NULL key */ /* NULL key */
status = pNtOpenKey(NULL, am, &attr); status = pNtOpenKey(NULL, am, &attr);
todo_wine ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08x\n", status);
ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08x\n", status);
/* Length > sizeof(OBJECT_ATTRIBUTES) */ /* Length > sizeof(OBJECT_ATTRIBUTES) */
attr.Length *= 2; attr.Length *= 2;
status = pNtOpenKey(&key, am, &attr); status = pNtOpenKey(&key, am, &attr);
todo_wine ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got: 0x%08x\n", status);
ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got: 0x%08x\n", status);
} }
static void test_NtCreateKey(void) static void test_NtCreateKey(void)
......
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