diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9e71ea4f8..d72d99bda 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2010-06-09 Corinna Vinschen + + * path.cc (symlink_info::check_shortcut): Use ro_u_empty rather than + local UNICODE_STRING object. + (symlink_info::check_sysfile): Ditto. Return immediately if NtOpenFile + failed to avoid closing random handle. Improve debug output in case + NtReadFile failed. + 2010-06-08 Corinna Vinschen * path.cc (symlink_info::check): Set h to NULL after closing handle diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 4173401e3..d5d103d9f 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -1685,14 +1685,13 @@ symlink_info::check_shortcut (HANDLE in_h) char *buf, *cp; unsigned short len; int res = 0; - UNICODE_STRING same = { 0, 0, (PWCHAR) L"" }; OBJECT_ATTRIBUTES attr; NTSTATUS status; HANDLE h; IO_STATUS_BLOCK io; FILE_STANDARD_INFORMATION fsi; - InitializeObjectAttributes (&attr, &same, 0, in_h, NULL); + InitializeObjectAttributes (&attr, &ro_u_empty, 0, in_h, NULL); status = NtOpenFile (&h, FILE_READ_DATA | SYNCHRONIZE, &attr, &io, FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT @@ -1773,25 +1772,24 @@ symlink_info::check_sysfile (HANDLE in_h) char cookie_buf[sizeof (SYMLINK_COOKIE) - 1]; char *srcbuf = tp.c_get (); int res = 0; - UNICODE_STRING same = { 0, 0, (PWCHAR) L"" }; OBJECT_ATTRIBUTES attr; NTSTATUS status; HANDLE h; IO_STATUS_BLOCK io; bool interix_symlink = false; - InitializeObjectAttributes (&attr, &same, 0, in_h, NULL); + InitializeObjectAttributes (&attr, &ro_u_empty, 0, in_h, NULL); status = NtOpenFile (&h, FILE_READ_DATA | SYNCHRONIZE, &attr, &io, FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT | FILE_SYNCHRONOUS_IO_NONALERT); if (!NT_SUCCESS (status)) - ; + return 0; else if (!NT_SUCCESS (status = NtReadFile (h, NULL, NULL, NULL, &io, cookie_buf, sizeof (cookie_buf), NULL, NULL))) { - debug_printf ("ReadFile1 failed"); + debug_printf ("ReadFile1 failed %p", status); if (status != STATUS_END_OF_FILE) set_error (EIO); }