]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: normalize_posix_path: fix error handling when .. is encountered
authorKen Brown <kbrown@cornell.edu>
Wed, 20 Jan 2021 15:12:58 +0000 (10:12 -0500)
committerKen Brown <kbrown@cornell.edu>
Fri, 22 Jan 2021 15:31:09 +0000 (10:31 -0500)
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):

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html

Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html

winsup/cygwin/path.cc
winsup/cygwin/release/3.2.0

index abd3687dfb69487bda2fafcabaddec6fcd7abc7f..6dc16280605bb3f80d8fed91b2bea76ef49f9d47 100644 (file)
@@ -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
index c18a848de34f40decf58ed185189fa7cbccc120b..43725cec2f8be80909b20fe8d13a3401da201e87 100644 (file)
@@ -48,3 +48,7 @@ Bug Fixes
 
 - Fix a bug in fstatat(2) on 32 bit that could cause it to return garbage.
   Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247399.html
+
+- Fix the errno when a path contains .. and the prefix exists but is
+  not a directory.
+  Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html
This page took 0.037308 seconds and 5 git commands to generate.