[PATCH] ntdll: Check for NULL attr in NtOpenKey (Coverity)
Marcus Meissner
meissner at suse.de
Tue Dec 15 04:39:23 CST 2009
Hi,
This checks for NULL attributes in NtOpenKey, also
enabling the testsuite.
Ciao, Marcus
---
dlls/ntdll/reg.c | 4 +++-
dlls/ntdll/tests/reg.c | 4 ----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c
index 7d24a9b..286dbdb 100644
--- a/dlls/ntdll/reg.c
+++ b/dlls/ntdll/reg.c
@@ -114,8 +114,10 @@ NTSTATUS WINAPI RtlpNtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJEC
NTSTATUS WINAPI NtOpenKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
{
NTSTATUS ret;
- DWORD len = attr->ObjectName->Length;
+ DWORD len;
+ if (!attr) return STATUS_ACCESS_VIOLATION;
+ len = attr->ObjectName->Length;
TRACE( "(%p,%s,%x,%p)\n", attr->RootDirectory,
debugstr_us(attr->ObjectName), access, retkey );
diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c
index 89f7c68..a061293 100644
--- a/dlls/ntdll/tests/reg.c
+++ b/dlls/ntdll/tests/reg.c
@@ -336,9 +336,6 @@ static void test_NtOpenKey(void)
OBJECT_ATTRIBUTES attr;
ACCESS_MASK am = KEY_READ;
- if (0)
- {
- /* Crashes Wine */
/* All NULL */
status = pNtOpenKey(NULL, 0, NULL);
ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08x\n", status);
@@ -347,7 +344,6 @@ static void test_NtOpenKey(void)
status = pNtOpenKey(&key, 0, NULL);
ok(status == STATUS_ACCESS_VIOLATION /* W2K3/XP/W2K */ || status == STATUS_INVALID_PARAMETER /* NT4 */,
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER(NT4), got: 0x%08x\n", status);
- }
InitializeObjectAttributes(&attr, &winetestpath, 0, 0, 0);
--
1.6.4.2
More information about the wine-patches
mailing list