Paul Vriens : ntdll: Fix return codes for NtCreateKey (with tests).

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 30 14:15:10 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 8a42a8c11a125c5a08518342faf53ec20006473c
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=8a42a8c11a125c5a08518342faf53ec20006473c

Author: Paul Vriens <Paul.Vriens at xs4all.nl>
Date:   Fri Jun 30 09:04:03 2006 +0200

ntdll: Fix return codes for NtCreateKey (with tests).

---

 dlls/ntdll/reg.c       |    3 ++-
 dlls/ntdll/tests/reg.c |   28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c
index d0c5e62..5a1f5c2 100644
--- a/dlls/ntdll/reg.c
+++ b/dlls/ntdll/reg.c
@@ -58,8 +58,9 @@ NTSTATUS WINAPI NtCreateKey( PHANDLE ret
     TRACE( "(%p,%s,%s,%lx,%lx,%p)\n", attr->RootDirectory, debugstr_us(attr->ObjectName),
            debugstr_us(class), options, access, retkey );
 
+    if (!retkey || !attr) return STATUS_ACCESS_VIOLATION;
+    if (attr->Length > sizeof(OBJECT_ATTRIBUTES)) return STATUS_INVALID_PARAMETER;
     if (attr->ObjectName->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
-    if (!retkey) return STATUS_INVALID_PARAMETER;
 
     SERVER_START_REQ( create_key )
     {
diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c
index 0b1cc43..654ae64 100644
--- a/dlls/ntdll/tests/reg.c
+++ b/dlls/ntdll/tests/reg.c
@@ -298,10 +298,38 @@ static void test_NtCreateKey(void)
     ACCESS_MASK am = GENERIC_ALL;
     NTSTATUS status;
 
+    /* All NULL */
+    status = pNtCreateKey(NULL, 0, NULL, 0, 0, 0, 0);
+    ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08lx\n", status);
+
+    /* Only the key */
+    status = pNtCreateKey(&key, 0, NULL, 0, 0, 0, 0);
+    ok(status == STATUS_ACCESS_VIOLATION /* W2K3/XP/W2K */ || status == STATUS_INVALID_PARAMETER /* NT4 */,
+        "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER(NT4), got: 0x%08lx\n", status);
+
+    /* Only accessmask */
+    status = pNtCreateKey(NULL, am, NULL, 0, 0, 0, 0);
+    ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08lx\n", status);
+
+    /* Key and accessmask */
+    status = pNtCreateKey(&key, am, NULL, 0, 0, 0, 0);
+    ok(status == STATUS_ACCESS_VIOLATION /* W2K3/XP/W2K */ || status == STATUS_INVALID_PARAMETER /* NT4 */,
+        "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER(NT4), got: 0x%08lx\n", status);
+
     InitializeObjectAttributes(&attr, &winetestpath, 0, 0, 0);
+
+    /* Only attributes */
+    status = pNtCreateKey(NULL, 0, &attr, 0, 0, 0, 0);
+    ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08lx\n", status);
+
     status = pNtCreateKey(&key, am, &attr, 0, 0, 0, 0);
     ok(status == STATUS_SUCCESS, "NtCreateKey Failed: 0x%08lx\n", status);
 
+    /* Length > sizeof(OBJECT_ATTRIBUTES) */
+    attr.Length *= 2;
+    status = pNtCreateKey(&key, am, &attr, 0, 0, 0, 0);
+    ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got: 0x%08lx\n", status);
+
     pNtClose(&key);
 }
 




More information about the wine-cvs mailing list