Hans Leidekker : advapi32: Return an error from RegSetValueExW if passed a NULL data pointer and non-zero size.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 5 15:01:27 CST 2015


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Mon Jan  5 13:18:50 2015 +0100

advapi32: Return an error from RegSetValueExW if passed a NULL data pointer and non-zero size.

---

 dlls/advapi32/registry.c       |  2 +-
 dlls/advapi32/tests/registry.c | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 8e33ab3..620dd6a 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -1201,7 +1201,7 @@ LSTATUS WINAPI RegSetValueExW( HKEY hkey, LPCWSTR name, DWORD reserved,
 
     /* no need for version check, not implemented on win9x anyway */
 
-    if (data && ((ULONG_PTR)data >> 16) == 0) return ERROR_NOACCESS;
+    if ((data && ((ULONG_PTR)data >> 16) == 0) || (!data && count)) return ERROR_NOACCESS;
 
     if (count && is_string(type))
     {
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index bcf3d7d..3acda0e 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -436,6 +436,21 @@ static void test_set_value(void)
     ret = RegSetValueExW(hkey_main, name2W, 0, REG_DWORD, (const BYTE *)1, 1);
     ok(ret == ERROR_NOACCESS, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret, GetLastError());
 
+    if (pRegGetValueA) /* avoid a crash on Windows 2000 */
+    {
+        ret = RegSetValueExW(hkey_main, NULL, 0, REG_SZ, NULL, 4);
+        ok(ret == ERROR_NOACCESS, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret, GetLastError());
+
+        ret = RegSetValueExW(hkey_main, NULL, 0, REG_SZ, NULL, 0);
+        ok(ret == ERROR_SUCCESS, "got %d\n", ret);
+
+        ret = RegSetValueExW(hkey_main, NULL, 0, REG_DWORD, NULL, 4);
+        ok(ret == ERROR_NOACCESS, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret, GetLastError());
+
+        ret = RegSetValueExW(hkey_main, NULL, 0, REG_DWORD, NULL, 0);
+        ok(ret == ERROR_SUCCESS, "got %d\n", ret);
+    }
+
     /* RegSetKeyValue */
     if (!pRegSetKeyValueW)
         win_skip("RegSetKeyValue() is not supported.\n");
@@ -464,6 +479,12 @@ static void test_set_value(void)
         ret = pRegSetKeyValueW(hkey_main, subkeyW, name1W, REG_SZ, NULL, 0);
         ok(ret == ERROR_SUCCESS, "got %d\n", ret);
 
+        ret = pRegSetKeyValueW(hkey_main, subkeyW, name1W, REG_SZ, NULL, 4);
+        ok(ret == ERROR_NOACCESS, "got %d\n", ret);
+
+        ret = pRegSetKeyValueW(hkey_main, subkeyW, name1W, REG_DWORD, NULL, 4);
+        ok(ret == ERROR_NOACCESS, "got %d\n", ret);
+
         RegCloseKey(subkey);
     }
 }




More information about the wine-cvs mailing list