public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: normalize_win32_path: improve error checking Date: Fri, 27 Sep 2019 17:37:00 -0000 [thread overview] Message-ID: <20190927173730.106970.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=283cb372e4e25d1d11123d98e3d14e85b525e48d commit 283cb372e4e25d1d11123d98e3d14e85b525e48d Author: Ken Brown <kbrown@cornell.edu> Date: Wed Sep 25 14:18:18 2019 -0400 Cygwin: normalize_win32_path: improve error checking If the source path starts with the Win32 long path prefix '\\?\' or the NT object directory prefix '\??\', require the prefix to be followed by 'UNC\' or '<drive letter>:\'. Otherwise return EINVAL. This fixes the assertion failure in symlink_info::check that was reported here: https://cygwin.com/ml/cygwin/2019-09/msg00228.html That assertion failure was caused by normalize_win32_path returning a path with no backslashes when the source path was '\\?\DRIVE'. Diff: --- winsup/cygwin/path.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 2fbacd8..f610035 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -1406,15 +1406,18 @@ normalize_win32_path (const char *src, char *dst, char *&tail) bool beg_src_slash = isdirsep (src[0]); tail = dst; - /* Skip long path name prefixes in Win32 or NT syntax. */ + /* Skip Win32 long path name prefix and NT object directory prefix. */ if (beg_src_slash && (src[1] == '?' || isdirsep (src[1])) && src[2] == '?' && isdirsep (src[3])) { src += 4; - if (src[1] != ':') /* native UNC path */ + if (isdrive (src) && isdirsep (src[2])) + beg_src_slash = false; + else if (!strncmp (src, "UNC", 3) && isdirsep (src[3])) + /* native UNC path */ src += 2; /* Fortunately the first char is not copied... */ else - beg_src_slash = false; + return EINVAL; } if (beg_src_slash && isdirsep (src[1])) {
reply other threads:[~2019-09-27 17:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190927173730.106970.qmail@sourceware.org \ --to=kbrown@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).