Commit c0995c2c authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

Fix two more corner cases in UNIXFS_get_unix_path and UNIXFS_path_to_pidl.

parent 83245092
...@@ -280,11 +280,17 @@ static BOOL UNIXFS_get_unix_path(LPCWSTR pszDosPath, char *pszCanonicalPath) ...@@ -280,11 +280,17 @@ static BOOL UNIXFS_get_unix_path(LPCWSTR pszDosPath, char *pszCanonicalPath)
if (cLinkLen + cTailLen + 1 > FILENAME_MAX) if (cLinkLen + cTailLen + 1 > FILENAME_MAX)
return FALSE; return FALSE;
/* Avoid double slashes. */
if (szSymlink[cLinkLen-1] == '/' && pPathTail[0] == '/') {
szSymlink[cLinkLen-1] = '\0';
cLinkLen--;
}
memcpy(szSymlink + cLinkLen, pPathTail, cTailLen + 1); memcpy(szSymlink + cLinkLen, pPathTail, cTailLen + 1);
memcpy(szPath, szSymlink, cLinkLen + cTailLen + 1); memcpy(szPath, szSymlink, cLinkLen + cTailLen + 1);
*pszCanonicalPath = '\0'; *pszCanonicalPath = '\0';
pCanonicalTail = pszCanonicalPath; pCanonicalTail = pszCanonicalPath;
pPathTail = szPath; pPathTail = szPath;
} else { } else {
/* Relative link. Expand into szPath and continue. */ /* Relative link. Expand into szPath and continue. */
char szTemp[FILENAME_MAX]; char szTemp[FILENAME_MAX];
...@@ -307,7 +313,7 @@ static BOOL UNIXFS_get_unix_path(LPCWSTR pszDosPath, char *pszCanonicalPath) ...@@ -307,7 +313,7 @@ static BOOL UNIXFS_get_unix_path(LPCWSTR pszDosPath, char *pszCanonicalPath)
pCanonicalTail += pPathTail - pElement; pCanonicalTail += pPathTail - pElement;
*pPathTail = cTemp; *pPathTail = cTemp;
} }
} while (pPathTail[0] == '/' && pPathTail[1]); /* Also handles paths terminated by '/' */ } while (pPathTail[0] == '/');
TRACE("--> %s\n", debugstr_a(pszCanonicalPath)); TRACE("--> %s\n", debugstr_a(pszCanonicalPath));
...@@ -440,6 +446,14 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -440,6 +446,14 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
} }
} }
/* Special case for the root folder. */
if (!strcmp(szCompletePath, "/")) {
*ppidl = pidl = (LPITEMIDLIST)SHAlloc(sizeof(USHORT));
if (!pidl) return FALSE;
pidl->mkid.cb = 0; /* Terminate the ITEMIDLIST */
return TRUE;
}
/* Remove trailing slash, if present */ /* Remove trailing slash, if present */
cPathLen = strlen(szCompletePath); cPathLen = strlen(szCompletePath);
if (szCompletePath[cPathLen-1] == '/') if (szCompletePath[cPathLen-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