setupapi/devinst: Struct size passed needs to be exact.
This commit is contained in:
parent
d91f3a93ae
commit
433ca7d8bd
|
@ -2885,9 +2885,8 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(
|
|||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize <
|
||||
offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + sizeof(char) ||
|
||||
DeviceInterfaceDetailData->cbSize > sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A)))
|
||||
if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize !=
|
||||
offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + sizeof(char)))
|
||||
{
|
||||
SetLastError(ERROR_INVALID_USER_BUFFER);
|
||||
return FALSE;
|
||||
|
|
|
@ -641,6 +641,15 @@ static void testGetDeviceInterfaceDetail(void)
|
|||
ok(!ret && GetLastError() == ERROR_INVALID_USER_BUFFER,
|
||||
"Expected ERROR_INVALID_USER_BUFFER, got %08x\n", GetLastError());
|
||||
detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, detail,
|
||||
size, &size, NULL);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_USER_BUFFER,
|
||||
"Expected ERROR_INVALID_USER_BUFFER, got %08x\n", GetLastError());
|
||||
/* Windows 2000 and up check for the exact size. Win9x returns ERROR_INVALID_PARAMETER
|
||||
* on every call (so doesn't get here) and NT4 doesn't have this function.
|
||||
*/
|
||||
detail->cbSize = offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + sizeof(char);
|
||||
ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, detail,
|
||||
size, &size, NULL);
|
||||
ok(ret, "SetupDiGetDeviceInterfaceDetailA failed: %d\n",
|
||||
|
|
Loading…
Reference in New Issue