Dan Kegel : advapi32: RegSetValueExW should not crash when passed 1 instead of L"1".

Alexandre Julliard julliard at winehq.org
Tue Aug 21 13:40:18 CDT 2012


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

Author: Dan Kegel <dank at kegel.com>
Date:   Mon Aug 20 09:12:18 2012 -0700

advapi32: RegSetValueExW should not crash when passed 1 instead of L"1".

---

 dlls/advapi32/registry.c       |    3 +++
 dlls/advapi32/tests/registry.c |    9 +++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index bf2e98a..d3b8edf 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -1177,6 +1177,9 @@ LSTATUS WINAPI RegSetValueExW( HKEY hkey, LPCWSTR name, DWORD reserved,
     UNICODE_STRING nameW;
 
     /* no need for version check, not implemented on win9x anyway */
+
+    if (data && ((ULONG_PTR)data >> 16) == 0) return ERROR_NOACCESS;
+
     if (count && is_string(type))
     {
         LPCWSTR str = (LPCWSTR)data;
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index c0a7ebf..870275e 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -346,6 +346,9 @@ static void test_set_value(void)
         /* Crashes on NT4, Windows 2000 and XP SP1 */
         ret = RegSetValueW(hkey_main, NULL, REG_SZ, NULL, 0);
         ok(ret == ERROR_INVALID_PARAMETER, "RegSetValueW should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret);
+
+        RegSetValueExA(hkey_main, name2A, 0, REG_SZ, (const BYTE *)1, 1);
+        RegSetValueExA(hkey_main, name2A, 0, REG_DWORD, (const BYTE *)1, 1);
     }
 
     ret = RegSetValueW(hkey_main, NULL, REG_SZ, string1W, sizeof(string1W));
@@ -395,6 +398,12 @@ static void test_set_value(void)
     ok(ret == ERROR_SUCCESS, "RegSetValueExW failed: %d, GLE=%d\n", ret, GetLastError());
     test_hkey_main_Value_A(name2A, string2A, sizeof(string2A));
     test_hkey_main_Value_W(name2W, string2W, sizeof(string2W));
+
+    /* test RegSetValueExW with data = 1 */
+    ret = RegSetValueExW(hkey_main, name2W, 0, REG_SZ, (const BYTE *)1, 1);
+    ok(ret == ERROR_NOACCESS, "RegSetValueExW should have failed with with ERROR_NOACCESS: %d, GLE=%d\n", ret, GetLastError());
+    ret = RegSetValueExW(hkey_main, name2W, 0, REG_DWORD, (const BYTE *)1, 1);
+    ok(ret == ERROR_NOACCESS, "RegSetValueExW should have failed with with ERROR_NOACCESS: %d, GLE=%d\n", ret, GetLastError());
 }
 
 static void create_test_entries(void)




More information about the wine-cvs mailing list