* 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.
This commit is contained in:
Corinna Vinschen 2010-06-09 12:32:14 +00:00
parent b5efabb284
commit 03c991fed4
2 changed files with 12 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2010-06-09 Corinna Vinschen <corinna@vinschen.de>
* 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 <corinna@vinschen.de>
* path.cc (symlink_info::check): Set h to NULL after closing handle

View File

@ -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);
}