Module: wine Branch: master Commit: 433ca7d8bd65c484107d2cd66cdc936275286b1e URL: http://source.winehq.org/git/wine.git/?a=commit;h=433ca7d8bd65c484107d2cd66c...
Author: Paul Vriens paul.vriens.wine@gmail.com Date: Mon Feb 25 20:19:53 2008 +0100
setupapi/devinst: Struct size passed needs to be exact.
---
dlls/setupapi/devinst.c | 5 ++--- dlls/setupapi/tests/devinst.c | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 5d4b79e..0e5aad5 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -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; diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 5dda333..dc6d9f7 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -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",