setupapi: SetupDiGetDeviceRegistryProperty should return ERROR_INVALID_DATA when buffer size is not 0 but buffer is NULL.

This commit is contained in:
Alexander Morozov 2008-04-17 20:28:14 +04:00 committed by Alexandre Julliard
parent 85861a4999
commit af5e168f16
2 changed files with 10 additions and 2 deletions

View File

@ -3110,6 +3110,11 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
if (PropertyBufferSize && PropertyBuffer == NULL)
{
SetLastError(ERROR_INVALID_DATA);
return FALSE;
}
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0]) if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
&& PropertyMap[Property].nameA) && PropertyMap[Property].nameA)
@ -3166,6 +3171,11 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
if (PropertyBufferSize && PropertyBuffer == NULL)
{
SetLastError(ERROR_INVALID_DATA);
return FALSE;
}
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0]) if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
&& PropertyMap[Property].nameW) && PropertyMap[Property].nameW)

View File

@ -917,7 +917,6 @@ static void testDeviceRegistryPropertyA()
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME,
NULL, NULL, buflen, NULL); NULL, NULL, buflen, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_DATA, ok(!ret && GetLastError() == ERROR_INVALID_DATA,
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
@ -1011,7 +1010,6 @@ static void testDeviceRegistryPropertyW()
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME,
NULL, NULL, buflen, NULL); NULL, NULL, buflen, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_DATA, ok(!ret && GetLastError() == ERROR_INVALID_DATA,
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);