Commit c3bfe66a authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

mpr: Small fixes to WNetGetConnection.

Convert unc\server\share to \\server\share and be more tolerant to null pointers if only length is requested.
parent 41b09917
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment