aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-12-18 15:37:19 +0000
committerCorinna Vinschen <corinna@vinschen.de>2008-12-18 15:37:19 +0000
commitdc7dfa3a828d1d8fa2914ff80b4c3bfcfbbddd78 (patch)
tree4533e50c5fb98fb41a1471d48221b299cd947d49
parent676c6177042e89d5d98e5e2634662527be6c66d3 (diff)
downloadnewlib-dc7dfa3a828d1d8fa2914ff80b4c3bfcfbbddd78.zip
newlib-dc7dfa3a828d1d8fa2914ff80b4c3bfcfbbddd78.tar.gz
newlib-dc7dfa3a828d1d8fa2914ff80b4c3bfcfbbddd78.tar.bz2
* path.cc (symlin_info::check): Set 4th parameter of
NtQueryDirectoryFile to NULL instead of 0 since it's a pointer. Simplify label and break from loop handling in symlink evaluation conditional expression. Drop a now useless break statement. Fix behaviour when searching for `foo' and then finding a `foo.lnk' which is no shortcut.
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/path.cc49
2 files changed, 35 insertions, 23 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 16c1062..fd117c7 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,12 @@
+2008-12-18 Corinna Vinschen <corinna@vinschen.de>
+
+ * path.cc (symlin_info::check): Set 4th parameter of
+ NtQueryDirectoryFile to NULL instead of 0 since it's a pointer.
+ Simplify label and break from loop handling in symlink evaluation
+ conditional expression. Drop a now useless break statement. Fix
+ behaviour when searching for `foo' and then finding a `foo.lnk'
+ which is no shortcut.
+
2008-12-16 Christian Franke <franke@computer.org>
* fhandler_registry.cc (DEFAULT_VALUE_NAME): Remove constant.
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index bb9bb98..22deb54 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2407,7 +2407,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt,
}
else
{
- status = NtQueryDirectoryFile (dir, NULL, NULL, 0, &io,
+ status = NtQueryDirectoryFile (dir, NULL, NULL, NULL, &io,
&fdi_buf, sizeof fdi_buf,
FileDirectoryInformation,
TRUE, &basename, TRUE);
@@ -2458,16 +2458,25 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt,
{
/* If searching for `foo' and then finding a `foo.lnk' which is
no shortcut, return the same as if file not found. */
- if (!suffix.lnk_match () || !ext_tacked_on)
- goto file_not_symlink;
-
- /* in case we're going to tack *another* .lnk on this filename. */
- fileattr = INVALID_FILE_ATTRIBUTES;
- continue;
+ if (ext_tacked_on)
+ {
+ fileattr = INVALID_FILE_ATTRIBUTES;
+ set_error (ENOENT);
+ continue;
+ }
}
- if (contents[0] == ':' && contents[1] == '\\'
- && parse_device (contents))
- goto file_not_symlink;
+ else if (contents[0] != ':' || contents[1] != '\\'
+ || !parse_device (contents))
+ break;
+ }
+
+ /* If searching for `foo' and then finding a `foo.lnk' which is
+ no shortcut, return the same as if file not found. */
+ else if (suffix.lnk_match () && ext_tacked_on)
+ {
+ fileattr = INVALID_FILE_ATTRIBUTES;
+ set_error (ENOENT);
+ continue;
}
/* Reparse points are potentially symlinks. This check must be
@@ -2478,8 +2487,8 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt,
else if (fileattr & FILE_ATTRIBUTE_REPARSE_POINT)
{
res = check_reparse_point (h);
- if (!res)
- goto file_not_symlink;
+ if (res)
+ break;
}
/* This is the old Cygwin method creating symlinks. A symlink will
@@ -2489,8 +2498,8 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt,
== FILE_ATTRIBUTE_SYSTEM)
{
res = check_sysfile (h);
- if (!res)
- goto file_not_symlink;
+ if (res)
+ break;
}
/* If the file could be opened with FILE_READ_EA, and if it's on a
@@ -2499,17 +2508,11 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt,
else if (fs.is_nfs () && !no_ea && !(fileattr & FILE_ATTRIBUTE_DIRECTORY))
{
res = check_nfs_symlink (h);
- if (!res)
- goto file_not_symlink;
+ if (res)
+ break;
}
- /* Normal file. */
- else
- goto file_not_symlink;
-
- break;
-
-
+ /* Normal file. */
file_not_symlink:
issymlink = false;
syscall_printf ("%s", isdevice ? "is a device" : "not a symlink");