Commit 433ca7d8 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

setupapi/devinst: Struct size passed needs to be exact.

parent d91f3a93
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment