diff options
author | Christopher Faylor <me@cgf.cx> | 2001-04-22 16:19:27 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-04-22 16:19:27 +0000 |
commit | 96dc5dd7e594df1a835f3303e9fee5f5a8c78206 (patch) | |
tree | 479ef1db203d6fd56805aa4a7ee7374fe0460437 /winsup/cygwin/path.cc | |
parent | da77d416c54dda36b2284e9713bb2f5251d15a1c (diff) | |
download | newlib-96dc5dd7e594df1a835f3303e9fee5f5a8c78206.zip newlib-96dc5dd7e594df1a835f3303e9fee5f5a8c78206.tar.gz newlib-96dc5dd7e594df1a835f3303e9fee5f5a8c78206.tar.bz2 |
* shortcut.c (check_shortcut): Close input file handle before returning.
* path.cc (check_sysfile): Ditto.
(symlink_info::check): Rely on opened file handle being closed by symlink
checking routines. Set ext_tacked_on when .lnk is detected.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 137d913..c218a16 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2504,6 +2504,8 @@ check_sysfile (const char *path, DWORD fileattr, HANDLE h, } syscall_printf ("%d = symlink.check_sysfile (%s, %s) (%p)", res, path, contents, *pflags); + + CloseHandle (h); return res; } @@ -2698,29 +2700,29 @@ symlink_info::check (const char *path, const suffix_info *suffixes, res = -1; if (h == INVALID_HANDLE_VALUE) goto file_not_symlink; - else if (sym_check == 1 - && !(res = check_shortcut (suffix.path, fileattr, h, - contents, &error, &pflags))) + + switch (sym_check) { - CloseHandle (h); - /* 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 ()) + case 1: + res = check_shortcut (suffix.path, fileattr, h, contents, &error, &pflags); + if (res) { - fileattr = (DWORD)-1; - continue; /* in case we're going to tack *another* .lnk on this filename. */ + ext_tacked_on = 1; + break; } - goto file_not_symlink; - } - else if (sym_check == 2 && - !(res = check_sysfile (suffix.path, fileattr, h, - contents, &error, &pflags))) - { - CloseHandle (h); - goto file_not_symlink; + /* 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 ()) + goto file_not_symlink; + + fileattr = (DWORD) -1; + continue; /* in case we're going to tack *another* .lnk on this filename. */ + case 2: + res = check_sysfile (suffix.path, fileattr, h, contents, &error, &pflags); + if (!res) + goto file_not_symlink; + break; } - - CloseHandle (h); break; } goto out; |