Module: wine Branch: master Commit: 5711f03e8479936ac5e3bc71ba7987f6b7cb5586 URL: https://gitlab.winehq.org/wine/wine/-/commit/5711f03e8479936ac5e3bc71ba7987f...
Author: Zebediah Figura zfigura@codeweavers.com Date: Wed Nov 16 19:29:30 2022 -0600
setupapi: Correctly calculate the required size in SetupDiGetDeviceInterfaceDetailA().
Don't include the null terminator twice.
---
dlls/setupapi/devinst.c | 2 +- dlls/setupapi/tests/devinst.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 901af4650c8..930ed670e84 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -3003,7 +3003,7 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(HDEVINFO devinfo, SP_DEVICE_INTERFA
if (iface->symlink) bytesNeeded += WideCharToMultiByte(CP_ACP, 0, iface->symlink, -1, - NULL, 0, NULL, NULL); + NULL, 0, NULL, NULL) - 1; if (DeviceInterfaceDetailDataSize >= bytesNeeded) { if (iface->symlink) diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 9d6a61c08c8..2a33da2d72a 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -1232,7 +1232,7 @@ static void test_device_iface_detail(void) ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#lx.\n", GetLastError());
expected_size = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath[strlen(path) + 1]); - todo_wine ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size); + ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size); detail = heap_alloc(size * 2);
detail->cbSize = 0; @@ -1255,9 +1255,8 @@ static void test_device_iface_detail(void) SetLastError(0xdeadbeef); size = 0xdeadbeef; ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, expected_size, &size, NULL); - todo_wine ok(ret, "Failed to get interface detail, error %#lx.\n", GetLastError()); - if (ret) - ok(!strcasecmp(path, detail->DevicePath), "Got unexpected path %s.\n", detail->DevicePath); + ok(ret, "Failed to get interface detail, error %#lx.\n", GetLastError()); + ok(!strcasecmp(path, detail->DevicePath), "Got unexpected path %s.\n", detail->DevicePath); todo_wine ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size);
SetLastError(0xdeadbeef);