4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-18 23:12:15 +08:00

realpath: Handle Win32 and NT long path prefixes

So far drive letter paths have been handled special since path_conv
leaves the incoming path untouched except for converting backslashes
to forward slashes.  However, if the incoming path starts with a
long path prefix, the same problem occurs.  Therefore handle all
paths starting with a backslahs the same way.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2016-05-31 16:33:21 +02:00
parent 357da5bc32
commit 5c759ab2f4

View File

@ -3560,10 +3560,12 @@ realpath (const char *__restrict path, char *__restrict resolved)
potentially invalid resolved. */ potentially invalid resolved. */
__try __try
{ {
/* Win32 drive letter paths have to be converted to a POSIX path first, /* Win32 drive letter paths and, generally, any path starting with a
because path_conv leaves the incoming path untouched except for backslash, have to be converted to a POSIX path first, because
converting backslashes to forward slashes. */ path_conv leaves the incoming path untouched except for converting
if (isdrive (path)) backslashes to forward slashes. This also covers '\\?\ and '\??\'
path prefixes. */
if (isdrive (path) || path[0] == '\\')
{ {
tpath = tp.c_get (); tpath = tp.c_get ();
mount_table->conv_to_posix_path (path, tpath, 0); mount_table->conv_to_posix_path (path, tpath, 0);