[PATCH] wnet: Make WNetGetUniversalNameW return required size when buffer is too small and add test

Fabian Maurer dark.shadow4 at web.de
Fri Jul 20 14:05:05 CDT 2018


The pointer is set to the required size not only when the input size
is 0, but generally when it is too small.

Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
 dlls/mpr/tests/mpr.c | 5 ++++-
 dlls/mpr/wnet.c      | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/mpr/tests/mpr.c b/dlls/mpr/tests/mpr.c
index fc067d98c4..3e5ca099eb 100644
--- a/dlls/mpr/tests/mpr.c
+++ b/dlls/mpr/tests/mpr.c
@@ -51,11 +51,14 @@ static void test_WNetGetUniversalName(void)
 
         ok(info_size == sizeof(buffer), "Got wrong size: %u\n", info_size);
 
-        fail_size = 0;
+        fail_size = 1;
         ret = WNetGetUniversalNameA(driveA, UNIVERSAL_NAME_INFO_LEVEL,
                 buffer, &fail_size);
         if(drive_type == DRIVE_REMOTE)
+        {
             todo_wine ok(ret == WN_BAD_VALUE || ret == WN_MORE_DATA, "WNetGetUniversalNameA failed: %08x\n", ret);
+            ok(fail_size > 1, "Got %d\n", fail_size);
+        }
         else
             ok(ret == WN_NOT_CONNECTED || ret == WN_NO_NET_OR_BAD_PATH,
                 "(%s) WNetGetUniversalNameW gave wrong error: %u\n", driveA, ret);
diff --git a/dlls/mpr/wnet.c b/dlls/mpr/wnet.c
index 78759ecb15..002ab7bb52 100644
--- a/dlls/mpr/wnet.c
+++ b/dlls/mpr/wnet.c
@@ -2386,6 +2386,7 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel,
         size = sizeof(*info) + (lstrlenW(lpLocalPath) + 1) * sizeof(WCHAR);
         if (*lpBufferSize < size)
         {
+            *lpBufferSize = size;
             err = WN_MORE_DATA;
             break;
         }
-- 
2.18.0




More information about the wine-devel mailing list