Fix #5603: Prefer absolute path for /drive: syntax.

This commit is contained in:
Armin Novak 2019-09-24 15:44:34 +02:00
parent ab0004c823
commit b1d0eaff6d
3 changed files with 30 additions and 3 deletions

View File

@ -103,9 +103,12 @@ static BOOL freerdp_client_add_drive(rdpSettings* settings, const char* path, co
/* Path was entered as secondary argument, swap */
if (PathFileExistsA(name))
{
const char* tmp = path;
path = name;
name = tmp;
if (!PathFileExistsA(path) || (!PathIsRelativeA(name) && PathIsRelativeA(path)))
{
const char* tmp = path;
path = name;
name = tmp;
}
}
}

View File

@ -288,6 +288,9 @@ WINPR_API BOOL PathMakePathA(LPCSTR path, LPSECURITY_ATTRIBUTES lpAttributes);
#if !defined(_WIN32) || defined(_UWP)
WINPR_API BOOL PathIsRelativeA(LPCSTR pszPath);
WINPR_API BOOL PathIsRelativeW(LPCWSTR pszPath);
WINPR_API BOOL PathFileExistsA(LPCSTR pszPath);
WINPR_API BOOL PathFileExistsW(LPCWSTR pszPath);

View File

@ -521,6 +521,27 @@ BOOL PathMakePathA(LPCSTR path, LPSECURITY_ATTRIBUTES lpAttributes)
#if !defined(_WIN32) || defined(_UWP)
BOOL PathIsRelativeA(LPCSTR pszPath)
{
if (!pszPath)
return FALSE;
return pszPath[0] != '/';
}
BOOL PathIsRelativeW(LPCWSTR pszPath)
{
LPSTR lpFileNameA = NULL;
BOOL ret;
if (ConvertFromUnicode(CP_UTF8, 0, pszPath, -1, &lpFileNameA, 0, NULL, NULL) < 1)
return FALSE;
ret = PathIsRelativeA(lpFileNameA);
free(lpFileNameA);
return ret;
}
BOOL PathFileExistsA(LPCSTR pszPath)
{
struct stat stat_info;