Cygwin: fix return value of symlink_info::check
Currently it is possible for symlink_info::check to return -1 in case
we're searching for foo and find foo.lnk that is not a Cygwin symlink.
This contradicts the new meaning attached to a negative return value
in commit 19d59ce75d
. Fix this by setting "res" to 0 at the beginning
of the main loop and not seting it to -1 later.
Also fix the commentary preceding the function definition to reflect
the current behavior.
Addresses: https://cygwin.com/pipermail/cygwin/2022-August/252030.html
This commit is contained in:
parent
34872ce1a1
commit
5cdf8ade28
|
@ -3027,19 +3027,16 @@ symlink_info::parse_device (const char *contents)
|
||||||
/* Check if PATH is a symlink. PATH must be a valid Win32 path name.
|
/* Check if PATH is a symlink. PATH must be a valid Win32 path name.
|
||||||
|
|
||||||
If PATH is a symlink, put the value of the symlink--the file to
|
If PATH is a symlink, put the value of the symlink--the file to
|
||||||
which it points--into BUF. The value stored in BUF is not
|
which it points--into CONTENTS.
|
||||||
necessarily null terminated. BUFLEN is the length of BUF; only up
|
|
||||||
to BUFLEN characters will be stored in BUF. BUF may be NULL, in
|
|
||||||
which case nothing will be stored.
|
|
||||||
|
|
||||||
Set *SYML if PATH is a symlink.
|
Set PATH_SYMLINK if PATH is a symlink.
|
||||||
|
|
||||||
Set *EXEC if PATH appears to be executable. This is an efficiency
|
If PATH is a symlink, return the length stored into CONTENTS. If
|
||||||
hack because we sometimes have to open the file anyhow. *EXEC will
|
the inner components of PATH contain native symlinks or junctions,
|
||||||
not be set for every executable file.
|
or if the drive is a virtual drive, compare PATH with the result
|
||||||
|
returned by GetFinalPathNameByHandleA. If they differ, store the
|
||||||
Return -1 on error, 0 if PATH is not a symlink, or the length
|
final path in CONTENTS and return the negative of its length. In
|
||||||
stored into BUF if PATH is a symlink. */
|
all other cases, return 0. */
|
||||||
|
|
||||||
int
|
int
|
||||||
symlink_info::check (char *path, const suffix_info *suffixes, fs_info &fs,
|
symlink_info::check (char *path, const suffix_info *suffixes, fs_info &fs,
|
||||||
|
@ -3094,6 +3091,7 @@ restart:
|
||||||
|
|
||||||
while (suffix.next ())
|
while (suffix.next ())
|
||||||
{
|
{
|
||||||
|
res = 0;
|
||||||
error = 0;
|
error = 0;
|
||||||
get_nt_native_path (suffix.path, upath, mount_flags & MOUNT_DOS);
|
get_nt_native_path (suffix.path, upath, mount_flags & MOUNT_DOS);
|
||||||
if (h)
|
if (h)
|
||||||
|
@ -3345,8 +3343,6 @@ restart:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = -1;
|
|
||||||
|
|
||||||
/* Reparse points are potentially symlinks. This check must be
|
/* Reparse points are potentially symlinks. This check must be
|
||||||
performed before checking the SYSTEM attribute for sysfile
|
performed before checking the SYSTEM attribute for sysfile
|
||||||
symlinks, since reparse points can have this flag set, too. */
|
symlinks, since reparse points can have this flag set, too. */
|
||||||
|
|
|
@ -35,3 +35,7 @@ Bug Fixes
|
||||||
- Fix a problem that prevented some symbolic links to /cygdrive/C,
|
- Fix a problem that prevented some symbolic links to /cygdrive/C,
|
||||||
/cygdrive/./c, /cygdrive//c, etc. from working.
|
/cygdrive/./c, /cygdrive//c, etc. from working.
|
||||||
Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251994.html
|
Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251994.html
|
||||||
|
|
||||||
|
- Fix a path handling bug that could cause a non-existing file to be
|
||||||
|
treated as the current directory.
|
||||||
|
Addresses: https://cygwin.com/pipermail/cygwin/2022-August/252030.html
|
||||||
|
|
Loading…
Reference in New Issue