wnet: Make WNetGetUniversalNameW return required size when buffer is too small and add test.

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@web.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Fabian Maurer 2018-07-20 21:05:05 +02:00 committed by Alexandre Julliard
parent 7ec1ae2bef
commit 8ca2938757
2 changed files with 5 additions and 1 deletions

View File

@ -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);

View File

@ -2385,6 +2385,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;
}