public inbox for
help / color / mirror / Atom feed
From: Ken Brown <>
Subject: [newlib-cygwin] Cygwin: normalize_posix_path: fix error handling when .. is encountered
Date: Fri, 22 Jan 2021 15:44:31 +0000 (GMT)	[thread overview]
Message-ID: <> (raw);h=4aefad2bb827afa273fcd768bd06dd618d41ae75

commit 4aefad2bb827afa273fcd768bd06dd618d41ae75
Author: Ken Brown <>
Date:   Wed Jan 20 10:12:58 2021 -0500

    Cygwin: normalize_posix_path: fix error handling when .. is encountered
    When .. is in the source path and the path prefix exists but is not a
    directory, return ENOTDIR instead of ENOENT.  This fixes a POSIX
    compliance issue for realpath(3):

 winsup/cygwin/       | 4 +++-
 winsup/cygwin/release/3.2.0 | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/ b/winsup/cygwin/
index abd3687df..6dc162806 100644
--- a/winsup/cygwin/
+++ b/winsup/cygwin/
@@ -323,8 +323,10 @@ normalize_posix_path (const char *src, char *dst, char *&tail)
 			  if (!tp.check_usage (4, 3))
 			    return ELOOP;
 			  path_conv head (dst, PC_SYM_FOLLOW | PC_POSIX);
-			  if (!head.isdir())
+			  if (!head.exists ())
 			    return ENOENT;
+			  if (!head.isdir ())
+			    return ENOTDIR;
 			  /* At this point, dst is a normalized path.  If the
 			     normalized path created by path_conv does not
 			     match the normalized path we're just testing, then
diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
index c18a848de..43725cec2 100644
--- a/winsup/cygwin/release/3.2.0
+++ b/winsup/cygwin/release/3.2.0
@@ -48,3 +48,7 @@ Bug Fixes
 - Fix a bug in fstatat(2) on 32 bit that could cause it to return garbage.
+- Fix the errno when a path contains .. and the prefix exists but is
+  not a directory.
+  Addresses:

                 reply	other threads:[~2021-01-22 15:44 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be 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).