Detlef Riekenberg : advapi32: Check the output pointer first in RegOpenKey, with test.
Alexandre Julliard
julliard at winehq.org
Mon Jun 29 09:17:49 CDT 2009
Module: wine
Branch: master
Commit: 0ca3b3b423444e0febcec4f9c2e44940dca493ff
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0ca3b3b423444e0febcec4f9c2e44940dca493ff
Author: Detlef Riekenberg <wine.dev at web.de>
Date: Sun Jun 28 20:40:04 2009 +0200
advapi32: Check the output pointer first in RegOpenKey, with test.
---
dlls/advapi32/registry.c | 8 +++++++-
dlls/advapi32/tests/registry.c | 9 +++++++++
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 52de6c5..3762908 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -381,6 +381,9 @@ LSTATUS WINAPI RegOpenKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, REGSAM acc
*/
LSTATUS WINAPI RegOpenKeyW( HKEY hkey, LPCWSTR name, PHKEY retkey )
{
+ if (!retkey)
+ return ERROR_INVALID_PARAMETER;
+
if (!name || !*name)
{
*retkey = hkey;
@@ -402,10 +405,13 @@ LSTATUS WINAPI RegOpenKeyW( HKEY hkey, LPCWSTR name, PHKEY retkey )
*
* RETURNS
* Success: ERROR_SUCCESS
- * Failure: A standard Win32 error code. retkey is set to 0.
+ * Failure: A standard Win32 error code. When retkey is valid, *retkey is set to 0.
*/
LSTATUS WINAPI RegOpenKeyA( HKEY hkey, LPCSTR name, PHKEY retkey )
{
+ if (!retkey)
+ return ERROR_INVALID_PARAMETER;
+
if (!name || !*name)
{
*retkey = hkey;
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 47e76b2..ca82fa1 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -956,9 +956,18 @@ static void test_reg_open_key(void)
RegCloseKey(hkResult);
/* send in NULL hkResult */
+ SetLastError(0xdeadbeef);
ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", NULL);
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+ SetLastError(0xdeadbeef);
+ ret = RegOpenKeyA(HKEY_CURRENT_USER, NULL, NULL);
+ ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+
+ SetLastError(0xdeadbeef);
+ ret = RegOpenKeyA(NULL, NULL, NULL);
+ ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+
/* beginning backslash character */
ret = RegOpenKeyA(HKEY_CURRENT_USER, "\\Software\\Wine\\Test", &hkResult);
ok(ret == ERROR_BAD_PATHNAME || /* NT/2k/XP */
More information about the wine-cvs
mailing list