Stefan Leichter : ntdll: Fix RtlCheckRegistryKey when called with empty path.

Alexandre Julliard julliard at winehq.org
Thu Mar 15 19:12:13 CDT 2018


Module: wine
Branch: master
Commit: f07e8ca8f01106b6d41a933f0ac393b30d505bad
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f07e8ca8f01106b6d41a933f0ac393b30d505bad

Author: Stefan Leichter <sle85276 at gmx.de>
Date:   Mon Mar 12 00:14:55 2018 +0100

ntdll: Fix RtlCheckRegistryKey when called with empty path.

Signed-off-by: Stefan Leichter <sle85276 at gmx.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/reg.c       |  4 +++-
 dlls/ntdll/tests/reg.c | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c
index 2dd75be..a34c863 100644
--- a/dlls/ntdll/reg.c
+++ b/dlls/ntdll/reg.c
@@ -1401,10 +1401,12 @@ NTSTATUS WINAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
 
     TRACE("(%d, %s)\n", RelativeTo, debugstr_w(Path));
 
-    if((!RelativeTo) && Path == NULL)
+    if(!RelativeTo && (Path == NULL || Path[0] == 0))
         return STATUS_OBJECT_PATH_SYNTAX_BAD;
     if(RelativeTo & RTL_REGISTRY_HANDLE)
         return STATUS_SUCCESS;
+    if((RelativeTo <= RTL_REGISTRY_USER) && (Path == NULL || Path[0] == 0))
+        return STATUS_SUCCESS;
 
     status = RTL_GetKeyHandle(RelativeTo, Path, &handle);
     if (handle) NtClose(handle);
diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c
index 7d2e566..ddd400e 100644
--- a/dlls/ntdll/tests/reg.c
+++ b/dlls/ntdll/tests/reg.c
@@ -671,6 +671,7 @@ static void test_RtlOpenCurrentUser(void)
 
 static void test_RtlCheckRegistryKey(void)
 {
+    static WCHAR empty[] = {0};
     NTSTATUS status;
 
     status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, winetestpath.Buffer);
@@ -678,6 +679,18 @@ static void test_RtlCheckRegistryKey(void)
 
     status = pRtlCheckRegistryKey((RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL), winetestpath.Buffer);
     ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and RTL_REGISTRY_OPTIONAL: 0x%08x\n", status);
+
+    status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, NULL);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and Path being NULL: 0x%08x\n", status);
+
+    status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, empty);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and Path being empty: 0x%08x\n", status);
+
+    status = pRtlCheckRegistryKey(RTL_REGISTRY_USER, NULL);
+    ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_USER and Path being NULL: 0x%08x\n", status);
+
+    status = pRtlCheckRegistryKey(RTL_REGISTRY_USER, empty);
+    ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_USER and Path being empty: 0x%08x\n", status);
 }
 
 static void test_NtFlushKey(void)




More information about the wine-cvs mailing list