[ntdll] Fix returncodes for NtCreateKey (with tests)
Paul Vriens
Paul.Vriens at xs4all.nl
Fri Jun 30 02:04:03 CDT 2006
Hi,
found some differences with Windows while doing testing for some
Coverity reports.
New tests pass on NT4/W2K/XP/W2K3 and Wine.
Some original tests still fail for NT4, haven't looked into that (yet).
Changelog
Fix returncodes for NtCreateKey
Cheers,
Paul.
---
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);
}
--
1.4.0
More information about the wine-patches
mailing list