mpr: Small fixes to WNetGetConnection

Maarten Lankhorst m.b.lankhorst at gmail.com
Tue May 22 14:35:16 CDT 2007


Convert unc\server\share to \\server\share and be more tolerant to null
pointers if only length is requested.
-------------- next part --------------
>From 85f3f09d582fb99f3f759ee4400eee1ce507ea80 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date: Tue, 22 May 2007 21:33:17 +0200
Subject: [PATCH] mpr: Small fixes to WNetGetConnection

---
 dlls/mpr/wnet.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/dlls/mpr/wnet.c b/dlls/mpr/wnet.c
index 8999b74..09d125c 100644
--- a/dlls/mpr/wnet.c
+++ b/dlls/mpr/wnet.c
@@ -3,6 +3,7 @@
  *
  * Copyright 1999 Ulrich Weigand
  * Copyright 2004 Juan Lang
+ * Copyright 2007 Maarten Lankhorst
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -1526,10 +1527,10 @@ DWORD WINAPI WNetGetConnectionA( LPCSTR lpLocalName,
 
     if (!lpLocalName)
         ret = WN_BAD_POINTER;
-    else if (!lpRemoteName)
-        ret = WN_BAD_POINTER;
     else if (!lpBufferSize)
         ret = WN_BAD_POINTER;
+    else if (!lpRemoteName && *lpBufferSize)
+        ret = WN_BAD_POINTER;
     else
     {
         int len = MultiByteToWideChar(CP_ACP, 0, lpLocalName, -1, NULL, 0);
@@ -1622,10 +1623,10 @@ DWORD WINAPI WNetGetConnectionW( LPCWSTR lpLocalName,
 
     if (!lpLocalName)
         ret = WN_BAD_POINTER;
-    else if (!lpRemoteName)
-        ret = WN_BAD_POINTER;
     else if (!lpBufferSize)
         ret = WN_BAD_POINTER;
+    else if (!lpRemoteName && *lpBufferSize)
+        ret = WN_BAD_POINTER;
     else if (!lpLocalName[0])
         ret = WN_BAD_LOCALNAME;
     else
@@ -1636,8 +1637,17 @@ DWORD WINAPI WNetGetConnectionW( LPCWSTR lpLocalName,
             {
             case DRIVE_REMOTE:
             {
-                WCHAR remote[MAX_PATH];
+                static const WCHAR unc[] = { 'u','n','c' };
+                WCHAR rremote[MAX_PATH], *remote = rremote;
                 if (!QueryDosDeviceW( lpLocalName, remote, MAX_PATH )) remote[0] = 0;
+                else if (!strncmpW(remote, unc, 3))
+                {
+                    remote += 2;
+                    remote[0] = '\\';
+                }
+                else if (remote[0] != '\\' || remote[1] != '\\')
+                    FIXME("Don't know how to convert %s to an unc\n", debugstr_w(remote));
+
                 if (strlenW(remote) + 1 > *lpBufferSize)
                 {
                     *lpBufferSize = strlenW(remote) + 1;
-- 
1.4.4.2



More information about the wine-patches mailing list