advapi32: Fail in RegEnumValue on missing value or val_count parameters.
This commit is contained in:
parent
94c6e3af3a
commit
eecd136cb7
|
@ -1912,8 +1912,8 @@ LSTATUS WINAPI RegEnumValueW( HKEY hkey, DWORD index, LPWSTR value, LPDWORD val_
|
|||
TRACE("(%p,%d,%p,%p,%p,%p,%p,%p)\n",
|
||||
hkey, index, value, val_count, reserved, type, data, count );
|
||||
|
||||
/* NT only checks count, not val_count */
|
||||
if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
|
||||
if ((data && !count) || reserved || !value || !val_count)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
if (!(hkey = get_special_root_hkey( hkey, 0 ))) return ERROR_INVALID_HANDLE;
|
||||
|
||||
total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR);
|
||||
|
@ -1997,8 +1997,8 @@ LSTATUS WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_c
|
|||
TRACE("(%p,%d,%p,%p,%p,%p,%p,%p)\n",
|
||||
hkey, index, value, val_count, reserved, type, data, count );
|
||||
|
||||
/* NT only checks count, not val_count */
|
||||
if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
|
||||
if ((data && !count) || reserved || !value || !val_count)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
if (!(hkey = get_special_root_hkey( hkey, 0 ))) return ERROR_INVALID_HANDLE;
|
||||
|
||||
total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR);
|
||||
|
|
|
@ -643,6 +643,32 @@ static void test_enum_value(void)
|
|||
ok( !strcmp( value, "Test" ), "value is '%s' instead of Test\n", value );
|
||||
ok( !strcmp( data, "foobar" ), "data is '%s' instead of foobar\n", data );
|
||||
|
||||
if (pRegGetValueA) /* avoid a crash on Windows 2000 */
|
||||
{
|
||||
/* no value and no val_count parameter */
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
strcpy( data, "xxxxxxxxxx" );
|
||||
res = RegEnumValueA( test_key, 0, NULL, NULL, NULL, &type, (BYTE*)data, &data_count );
|
||||
ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
|
||||
|
||||
/* no value parameter */
|
||||
val_count = 20;
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
strcpy( data, "xxxxxxxxxx" );
|
||||
res = RegEnumValueA( test_key, 0, NULL, &val_count, NULL, &type, (BYTE*)data, &data_count );
|
||||
ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
|
||||
|
||||
/* no val_count parameter */
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
strcpy( value, "xxxxxxxxxx" );
|
||||
strcpy( data, "xxxxxxxxxx" );
|
||||
res = RegEnumValueA( test_key, 0, value, NULL, NULL, &type, (BYTE*)data, &data_count );
|
||||
ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
|
||||
}
|
||||
|
||||
/* Unicode tests */
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -710,6 +736,32 @@ static void test_enum_value(void)
|
|||
ok( !memcmp( valueW, testW, sizeof(testW) ), "value is not 'Test'\n" );
|
||||
ok( !memcmp( dataW, foobarW, sizeof(foobarW) ), "data is not 'foobar'\n" );
|
||||
|
||||
if (pRegGetValueA) /* avoid a crash on Windows 2000 */
|
||||
{
|
||||
/* no valueW and no val_count parameter */
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
memcpy( dataW, xxxW, sizeof(xxxW) );
|
||||
res = RegEnumValueW( test_key, 0, NULL, NULL, NULL, &type, (BYTE*)dataW, &data_count );
|
||||
ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
|
||||
|
||||
/* no valueW parameter */
|
||||
val_count = 20;
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
memcpy( dataW, xxxW, sizeof(xxxW) );
|
||||
res = RegEnumValueW( test_key, 0, NULL, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
|
||||
ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
|
||||
|
||||
/* no val_count parameter */
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
memcpy( valueW, xxxW, sizeof(xxxW) );
|
||||
memcpy( dataW, xxxW, sizeof(xxxW) );
|
||||
res = RegEnumValueW( test_key, 0, valueW, NULL, NULL, &type, (BYTE*)dataW, &data_count );
|
||||
ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
|
||||
}
|
||||
|
||||
cleanup:
|
||||
RegDeleteKeyA(test_key, "");
|
||||
RegCloseKey(test_key);
|
||||
|
|
Loading…
Reference in New Issue