setupapi: Duplicate behaviour of native for SetupGetInfInformation with NULL ReturnBuffer and certain ReturnBufferSizes

Frank Richter frank.richter at gmail.com
Fri Aug 25 12:01:49 CDT 2006


SetupGetInfInformation does not set an error of ERROR_INVALID_PARAMETER
for all cases of ReturnBuffer == NULL and ReturnBufferSizes != 0: If the
size is <= 128, the function call actually succeeds. Added test for this
behaviour and changed SetupGetInfInformation accordingly.

-------------- next part --------------
>From 56fe5d1ec37328d3858c389844a498705d587356 Mon Sep 17 00:00:00 2001
From: Frank Richter frank.richter at gmail.com <frank.richter at gmail.com>
Date: Fri, 25 Aug 2006 18:57:26 +0200
Subject: [PATCH] setupapi: Duplicate behaviour of native for SetupGetInfInformation with NULL ReturnBuffer and certain ReturnBufferSizes
---
 dlls/setupapi/query.c       |    2 +-
 dlls/setupapi/tests/query.c |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c
index fd56f96..1043048 100644
--- a/dlls/setupapi/query.c
+++ b/dlls/setupapi/query.c
@@ -144,7 +144,7 @@ BOOL WINAPI SetupGetInfInformationW(LPCV
         return FALSE;
     }
 
-    if (!ReturnBuffer && ReturnBufferSize)
+    if (!ReturnBuffer && (ReturnBufferSize > 128))
     {
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
diff --git a/dlls/setupapi/tests/query.c b/dlls/setupapi/tests/query.c
index e823e7d..72aba18 100644
--- a/dlls/setupapi/tests/query.c
+++ b/dlls/setupapi/tests/query.c
@@ -184,6 +184,12 @@ static void test_SetupGetInfInformation(
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
        "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
+    /* set ReturnBuffer to NULL and ReturnBufferSize to 128 - non-zero, but succeeds! */
+    size = 128;
+    SetLastError(0xbeefcafe);
+    ret = pSetupGetInfInformationA(inf_filename, INFINFO_INF_NAME_IS_ABSOLUTE, NULL, size, &size);
+    ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
+
     info = HeapAlloc(GetProcessHeap(), 0, size);
 
     /* try valid ReturnBuffer but too small size */
-- 
1.4.1.1



More information about the wine-patches mailing list