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);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize <
|
if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize !=
|
||||||
offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + sizeof(char) ||
|
offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + sizeof(char)))
|
||||||
DeviceInterfaceDetailData->cbSize > sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A)))
|
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_USER_BUFFER);
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -641,6 +641,15 @@ static void testGetDeviceInterfaceDetail(void)
|
||||||
ok(!ret && GetLastError() == ERROR_INVALID_USER_BUFFER,
|
ok(!ret && GetLastError() == ERROR_INVALID_USER_BUFFER,
|
||||||
"Expected ERROR_INVALID_USER_BUFFER, got %08x\n", GetLastError());
|
"Expected ERROR_INVALID_USER_BUFFER, got %08x\n", GetLastError());
|
||||||
detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
|
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,
|
ret = pSetupDiGetDeviceInterfaceDetailA(set, &interfaceData, detail,
|
||||||
size, &size, NULL);
|
size, &size, NULL);
|
||||||
ok(ret, "SetupDiGetDeviceInterfaceDetailA failed: %d\n",
|
ok(ret, "SetupDiGetDeviceInterfaceDetailA failed: %d\n",
|
||||||
|
|
Loading…
Reference in New Issue