From ca027229d52d91c8a460b873bd2b454299369fad Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 15 Apr 2009 09:58:41 +0000 Subject: [PATCH] * path.cc (path_conv::get_wide_win32_path): Allow relative paths. (cygwin_conv_path): In case of CCP_POSIX_TO_WIN_W, convert relative paths to absolute paths if the relative pathname length exceeds MAX_PATH. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/path.cc | 23 +++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e566bb861..4bf2a5838 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2009-04-15 Corinna Vinschen + + * path.cc (path_conv::get_wide_win32_path): Allow relative paths. + (cygwin_conv_path): In case of CCP_POSIX_TO_WIN_W, convert relative + paths to absolute paths if the relative pathname length exceeds + MAX_PATH. + 2009-04-15 Corinna Vinschen * libc/bsdlib.cc: Align copyright with upstream. diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 576f9cdf4..e39a4b2fb 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -494,10 +494,11 @@ PWCHAR path_conv::get_wide_win32_path (PWCHAR wc) { get_nt_native_path (); - if (!wide_path || wide_path[1] != L'?') /* Native NT device path */ + if (!wide_path) return NULL; - wcscpy (wc, wide_path); - wc[1] = L'\\'; + wcpcpy (wc, wide_path); + if (wc[1] == L'?') + wc[1] = L'\\'; return wc; } @@ -2660,11 +2661,21 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to, } break; case CCP_POSIX_TO_WIN_W: - p.check ((const char *) from, - PC_POSIX | PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOWARN - | (relative ? PC_NOFULL : 0)); + p.check ((const char *) from, PC_POSIX | PC_SYM_FOLLOW + | PC_NO_ACCESS_CHECK | PC_NOWARN + | (relative ? PC_NOFULL : 0)); if (p.error) return_with_errno (p.error); + /* Relative Windows paths are always restricted to MAX_PATH chars. */ + if (relative && !isabspath (p.get_win32 ()) + && sys_mbstowcs (NULL, 0, p.get_win32 ()) > MAX_PATH) + { + /* Recreate as absolute path. */ + p.check ((const char *) from, PC_POSIX | PC_SYM_FOLLOW + | PC_NO_ACCESS_CHECK | PC_NOWARN); + if (p.error) + return_with_errno (p.error); + } lsiz = (p.get_wide_win32_path_len () + 1) * sizeof (WCHAR); break; case CCP_WIN_A_TO_POSIX: