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

This commit is contained in:
Hans Leidekker 2015-01-05 13:18:50 +01:00 committed by Alexandre Julliard
parent 823c037c9f
commit ff0ee8f8a8
2 changed files with 22 additions and 1 deletions

View File

@ -1201,7 +1201,7 @@ LSTATUS WINAPI RegSetValueExW( HKEY hkey, LPCWSTR name, DWORD reserved,
/* no need for version check, not implemented on win9x anyway */ /* 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)) if (count && is_string(type))
{ {

View File

@ -436,6 +436,21 @@ static void test_set_value(void)
ret = RegSetValueExW(hkey_main, name2W, 0, REG_DWORD, (const BYTE *)1, 1); 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()); 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 */ /* RegSetKeyValue */
if (!pRegSetKeyValueW) if (!pRegSetKeyValueW)
win_skip("RegSetKeyValue() is not supported.\n"); 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); ret = pRegSetKeyValueW(hkey_main, subkeyW, name1W, REG_SZ, NULL, 0);
ok(ret == ERROR_SUCCESS, "got %d\n", ret); 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); RegCloseKey(subkey);
} }
} }