public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Cygwin: normalize_posix_path: fix error handling when .. is encountered
@ 2021-01-20 15:40 Ken Brown
  2021-01-22  9:44 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Ken Brown @ 2021-01-20 15:40 UTC (permalink / raw)
  To: cygwin-patches

When .. is in the source path and the path prefix exists but is not a
directory, return ENOTDIR instead of ENOENT.  This fixes a failing
gnulib test of realpath(3).

Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html
---
 winsup/cygwin/path.cc       | 4 +++-
 winsup/cygwin/release/3.2.0 | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index abd3687df..6dc162806 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -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.
   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
-- 
2.30.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Cygwin: normalize_posix_path: fix error handling when .. is encountered
  2021-01-20 15:40 [PATCH] Cygwin: normalize_posix_path: fix error handling when .. is encountered Ken Brown
@ 2021-01-22  9:44 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2021-01-22  9:44 UTC (permalink / raw)
  To: cygwin-patches

On Jan 20 10:40, Ken Brown via Cygwin-patches wrote:
> When .. is in the source path and the path prefix exists but is not a
> directory, return ENOTDIR instead of ENOENT.  This fixes a failing
> gnulib test of realpath(3).
> 
> Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html
> ---
>  winsup/cygwin/path.cc       | 4 +++-
>  winsup/cygwin/release/3.2.0 | 4 ++++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
> index abd3687df..6dc162806 100644
> --- a/winsup/cygwin/path.cc
> +++ b/winsup/cygwin/path.cc
> @@ -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.
>    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
> -- 
> 2.30.0

Ok, please push.


Thanks,
Corinna

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-22  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 15:40 [PATCH] Cygwin: normalize_posix_path: fix error handling when .. is encountered Ken Brown
2021-01-22  9:44 ` Corinna Vinschen

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).