Module: wine Branch: master Commit: c3bfe66ade8d324e20a448d50b3a6fda2affa8bf URL: http://source.winehq.org/git/wine.git/?a=commit;h=c3bfe66ade8d324e20a448d50b...
Author: Maarten Lankhorst m.b.lankhorst@gmail.com Date: Tue May 22 21:33:17 2007 +0200
mpr: Small fixes to WNetGetConnection.
Convert unc\server\share to \server\share and be more tolerant to null pointers if only length is requested.
---
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..0abe0e8 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, 4)) + { + 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;