Andrew Eikum : mpr: Don' t succeed if drive is not remote in WNetGetUniversalName.

Alexandre Julliard julliard at winehq.org
Tue Jul 10 19:01:42 CDT 2012


Module: wine
Branch: master
Commit: 76880ff93320c4c0827de12254afb9adbd3e5250
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=76880ff93320c4c0827de12254afb9adbd3e5250

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Tue Jul 10 09:56:33 2012 -0500

mpr: Don't succeed if drive is not remote in WNetGetUniversalName.

---

 configure                  |    1 +
 configure.ac               |    1 +
 dlls/mpr/tests/Makefile.in |    7 +++++
 dlls/mpr/tests/mpr.c       |   65 ++++++++++++++++++++++++++++++++++++++++++++
 dlls/mpr/wnet.c            |   14 ++++++++-
 5 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 2646b0b..5f8b931 100755
--- a/configure
+++ b/configure
@@ -15288,6 +15288,7 @@ wine_fn_config_dll monodebg.vxd enable_win16
 wine_fn_config_dll mountmgr.sys enable_mountmgr_sys
 wine_fn_config_dll mouse.drv16 enable_win16
 wine_fn_config_dll mpr enable_mpr implib,po
+wine_fn_config_test dlls/mpr/tests mpr_test
 wine_fn_config_dll mprapi enable_mprapi implib
 wine_fn_config_dll msacm.dll16 enable_win16
 wine_fn_config_dll msacm32.drv enable_msacm32_drv
diff --git a/configure.ac b/configure.ac
index a85459d..67a0af6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2704,6 +2704,7 @@ WINE_CONFIG_DLL(monodebg.vxd,enable_win16)
 WINE_CONFIG_DLL(mountmgr.sys)
 WINE_CONFIG_DLL(mouse.drv16,enable_win16)
 WINE_CONFIG_DLL(mpr,,[implib,po])
+WINE_CONFIG_TEST(dlls/mpr/tests)
 WINE_CONFIG_DLL(mprapi,,[implib])
 WINE_CONFIG_DLL(msacm.dll16,enable_win16)
 WINE_CONFIG_DLL(msacm32.drv)
diff --git a/dlls/mpr/tests/Makefile.in b/dlls/mpr/tests/Makefile.in
new file mode 100644
index 0000000..655c49b
--- /dev/null
+++ b/dlls/mpr/tests/Makefile.in
@@ -0,0 +1,7 @@
+TESTDLL   = mpr.dll
+IMPORTS   = mpr
+
+C_SRCS = \
+	mpr.c
+
+ at MAKE_TEST_RULES@
diff --git a/dlls/mpr/tests/mpr.c b/dlls/mpr/tests/mpr.c
new file mode 100644
index 0000000..d54d80d
--- /dev/null
+++ b/dlls/mpr/tests/mpr.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2012 Andrew Eikum for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include <stdio.h>
+
+#include "windows.h"
+#include "winnetwk.h"
+#include "wine/test.h"
+
+static void test_WNetGetUniversalName(void)
+{
+    DWORD ret;
+    char buffer[1024];
+    DWORD drive_type, info_size;
+    char driveA[] = "A:\\";
+    WCHAR driveW[] = {'A',':','\\',0};
+
+    for(; *driveA <= 'Z'; ++*driveA, ++*driveW){
+        drive_type = GetDriveTypeW(driveW);
+
+        info_size = sizeof(buffer);
+        ret = WNetGetUniversalNameA(driveA, UNIVERSAL_NAME_INFO_LEVEL,
+                buffer, &info_size);
+
+        if(drive_type == DRIVE_REMOTE)
+            ok(ret == WN_NO_ERROR, "WNetGetUniversalNameA failed: %08x\n", ret);
+        else
+            ok(ret == ERROR_NOT_CONNECTED, "WNetGetUniversalNameA gave wrong error: %08x\n", ret);
+
+        ok(info_size == sizeof(buffer), "Got wrong size: %u\n", info_size);
+
+        info_size = sizeof(buffer);
+        ret = WNetGetUniversalNameW(driveW, UNIVERSAL_NAME_INFO_LEVEL,
+                buffer, &info_size);
+
+        if(drive_type == DRIVE_REMOTE)
+            ok(ret == WN_NO_ERROR, "WNetGetUniversalNameW failed: %08x\n", ret);
+        else
+            ok(ret == ERROR_NOT_CONNECTED, "WNetGetUniversalNameW gave wrong error: %08x\n", ret);
+
+        ok(info_size == sizeof(buffer), "Got wrong size: %u\n", info_size);
+    }
+}
+
+START_TEST(mpr)
+{
+    test_WNetGetUniversalName();
+}
diff --git a/dlls/mpr/wnet.c b/dlls/mpr/wnet.c
index 946f47e..bdc7ad0 100644
--- a/dlls/mpr/wnet.c
+++ b/dlls/mpr/wnet.c
@@ -1892,6 +1892,12 @@ DWORD WINAPI WNetGetUniversalNameA ( LPCSTR lpLocalPath, DWORD dwInfoLevel,
     {
         LPUNIVERSAL_NAME_INFOA info = lpBuffer;
 
+        if (GetDriveTypeA(lpLocalPath) != DRIVE_REMOTE)
+        {
+            err = ERROR_NOT_CONNECTED;
+            break;
+        }
+
         size = sizeof(*info) + lstrlenA(lpLocalPath) + 1;
         if (*lpBufferSize < size)
         {
@@ -1900,7 +1906,6 @@ DWORD WINAPI WNetGetUniversalNameA ( LPCSTR lpLocalPath, DWORD dwInfoLevel,
         }
         info->lpUniversalName = (char *)info + sizeof(*info);
         lstrcpyA(info->lpUniversalName, lpLocalPath);
-        *lpBufferSize = size;
         err = WN_NO_ERROR;
         break;
     }
@@ -1934,6 +1939,12 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel,
     {
         LPUNIVERSAL_NAME_INFOW info = lpBuffer;
 
+        if (GetDriveTypeW(lpLocalPath) != DRIVE_REMOTE)
+        {
+            err = ERROR_NOT_CONNECTED;
+            break;
+        }
+
         size = sizeof(*info) + (lstrlenW(lpLocalPath) + 1) * sizeof(WCHAR);
         if (*lpBufferSize < size)
         {
@@ -1942,7 +1953,6 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel,
         }
         info->lpUniversalName = (LPWSTR)((char *)info + sizeof(*info));
         lstrcpyW(info->lpUniversalName, lpLocalPath);
-        *lpBufferSize = size;
         err = WN_NO_ERROR;
         break;
     }




More information about the wine-cvs mailing list