public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] path_conv: do not get confused by a directory with `.lnk` suffix
@ 2022-01-17 20:20 Johannes Schindelin
  2022-01-18 11:05 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Schindelin @ 2022-01-17 20:20 UTC (permalink / raw)
  To: cygwin-patches

When trying to create a directory called `xyz` in the presence of a
directory `xyz.lnk`, the Cygwin runtime errors out with an `ENOENT`.

The root cause is actually a bit deeper: the `symlink_info::check()`
method tries to figure out whether the given path refers to a symbolic
link as emulated via `.lnk` files, but since it is a directory, that is
not the case, and that hypothesis is rejected.

However, the `fileattr` field is not cleared, so that a later
`.exists()` call on the instance mistakenly thinks that the symlink
actually exists. Let's clear that field.

This fixes https://github.com/msys2/msys2-runtime/issues/81

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Published-As: https://github.com/dscho/msys2-runtime/releases/tag/dont-confuse-a-xyz.lnk-directory-for-a-lnk-file-cygwin-v1
Fetch-It-Via: git fetch https://github.com/dscho/msys2-runtime dont-confuse-a-xyz.lnk-directory-for-a-lnk-file-cygwin-v1

 winsup/cygwin/path.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 5ab75f1055..87ac2404aa 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -3336,6 +3336,7 @@ restart:
 	 hasn't been found. */
       if (ext_tacked_on && !had_ext && (fileattr & FILE_ATTRIBUTE_DIRECTORY))
 	{
+	  fileattr = INVALID_FILE_ATTRIBUTES;
 	  set_error (ENOENT);
 	  continue;
 	}

base-commit: 1dd65a9ede44cafe8a52b8d85becca73d4fd7786
--
2.35.0.rc1.windows.1

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

* Re: [PATCH] path_conv: do not get confused by a directory with `.lnk` suffix
  2022-01-17 20:20 [PATCH] path_conv: do not get confused by a directory with `.lnk` suffix Johannes Schindelin
@ 2022-01-18 11:05 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2022-01-18 11:05 UTC (permalink / raw)
  To: cygwin-patches

On Jan 17 21:20, Johannes Schindelin wrote:
> When trying to create a directory called `xyz` in the presence of a
> directory `xyz.lnk`, the Cygwin runtime errors out with an `ENOENT`.
> 
> The root cause is actually a bit deeper: the `symlink_info::check()`
> method tries to figure out whether the given path refers to a symbolic
> link as emulated via `.lnk` files, but since it is a directory, that is
> not the case, and that hypothesis is rejected.
> 
> However, the `fileattr` field is not cleared, so that a later
> `.exists()` call on the instance mistakenly thinks that the symlink
> actually exists. Let's clear that field.
> 
> This fixes https://github.com/msys2/msys2-runtime/issues/81
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> Published-As: https://github.com/dscho/msys2-runtime/releases/tag/dont-confuse-a-xyz.lnk-directory-for-a-lnk-file-cygwin-v1
> Fetch-It-Via: git fetch https://github.com/dscho/msys2-runtime dont-confuse-a-xyz.lnk-directory-for-a-lnk-file-cygwin-v1
> 
>  winsup/cygwin/path.cc | 1 +
>  1 file changed, 1 insertion(+)

Pushed with adeded "Cygwin:" tag in commit summary.

Thanks,
Corinna

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

end of thread, other threads:[~2022-01-18 11:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17 20:20 [PATCH] path_conv: do not get confused by a directory with `.lnk` suffix Johannes Schindelin
2022-01-18 11:05 ` 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).