Module: wine Branch: master Commit: e1fa51f59cf050b9b3bc8da3aa8cc2228a1d507d URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=e1fa51f59cf050b9b3bc8da3...
Author: Frank Richter frank.richter@gmail.com Date: Fri Sep 22 13:17:46 2006 +0200
setupapi: Duplicate behaviour of native SetupGetInfInformation with NULL ReturnBuffer and certain ReturnBufferSizes.
---
dlls/setupapi/query.c | 15 ++++++++------- dlls/setupapi/tests/query.c | 14 +++++++++++++- 2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c index fd56f96..3e680eb 100644 --- a/dlls/setupapi/query.c +++ b/dlls/setupapi/query.c @@ -130,6 +130,7 @@ BOOL WINAPI SetupGetInfInformationW(LPCV { HINF inf; BOOL ret; + DWORD infSize;
TRACE("(%p, %ld, %p, %ld, %p)\n", InfSpec, SearchControl, ReturnBuffer, ReturnBufferSize, RequiredSize); @@ -144,12 +145,6 @@ BOOL WINAPI SetupGetInfInformationW(LPCV return FALSE; }
- if (!ReturnBuffer && ReturnBufferSize) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - switch (SearchControl) { case INFINFO_INF_SPEC_IS_HINF: @@ -181,7 +176,13 @@ BOOL WINAPI SetupGetInfInformationW(LPCV return FALSE; }
- ret = fill_inf_info(inf, ReturnBuffer, ReturnBufferSize, RequiredSize); + ret = fill_inf_info(inf, ReturnBuffer, ReturnBufferSize, &infSize); + if (!ReturnBuffer && (ReturnBufferSize >= infSize)) + { + SetLastError(ERROR_INVALID_PARAMETER); + ret = FALSE; + } + if (RequiredSize) *RequiredSize = infSize;
if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE) SetupCloseInfFile(inf); diff --git a/dlls/setupapi/tests/query.c b/dlls/setupapi/tests/query.c index e823e7d..0ac23da 100644 --- a/dlls/setupapi/tests/query.c +++ b/dlls/setupapi/tests/query.c @@ -177,13 +177,25 @@ static void test_SetupGetInfInformation( ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); ok(size != 0xdeadbeef, "Expected a valid size on return\n");
- /* set ReturnBuffer to NULL and ReturnBufferSize to non-zero */ + /* set ReturnBuffer to NULL and ReturnBufferSize to non-zero value 'size' */ SetLastError(0xbeefcafe); ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, &size); ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
+ /* set ReturnBuffer to NULL and ReturnBufferSize to non-zero value 'size-1' */ + ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size-1, &size); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); + + /* some tests for behaviour with a NULL RequiredSize pointer */ + ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, 0, NULL); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); + ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size - 1, NULL); + ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n"); + ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, NULL); + ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n"); + info = HeapAlloc(GetProcessHeap(), 0, size);
/* try valid ReturnBuffer but too small size */