mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-03-01 12:35:44 +08:00
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Rewrite checking
for executable file magic using a thread safe method and re-enable this code.
This commit is contained in:
parent
f5f0ae3e26
commit
2e9fe498f2
@ -1,3 +1,9 @@
|
|||||||
|
2007-08-21 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Rewrite checking
|
||||||
|
for executable file magic using a thread safe method and re-enable this
|
||||||
|
code.
|
||||||
|
|
||||||
2007-08-21 Corinna Vinschen <corinna@vinschen.de>
|
2007-08-21 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* syscalls.cc (unlink_nt): Drop one local FILE_BASIC_INFORMATION struct.
|
* syscalls.cc (unlink_nt): Drop one local FILE_BASIC_INFORMATION struct.
|
||||||
|
@ -570,37 +570,31 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf->st_mode |= S_IFREG;
|
buf->st_mode |= S_IFREG;
|
||||||
#if 0
|
|
||||||
/* FIXME: Is this code really necessary? There are already
|
|
||||||
two places in path_conv which look for executability.
|
|
||||||
Also, by using the fhandler's io HANDLE, a stat call might
|
|
||||||
change the file position for a short period of time in
|
|
||||||
a not thread-safe way. */
|
|
||||||
if (pc.exec_state () == dont_know_if_executable)
|
if (pc.exec_state () == dont_know_if_executable)
|
||||||
{
|
{
|
||||||
DWORD cur, done;
|
UNICODE_STRING same;
|
||||||
LONG curhigh = 0;
|
OBJECT_ATTRIBUTES attr;
|
||||||
char magic[3];
|
HANDLE h;
|
||||||
|
IO_STATUS_BLOCK io;
|
||||||
|
|
||||||
/* First retrieve current position, set to beginning
|
RtlInitUnicodeString (&same, L"");
|
||||||
of file if not already there. */
|
InitializeObjectAttributes (&attr, &same, 0, get_handle (), NULL);
|
||||||
cur = SetFilePointer (get_handle (), 0, &curhigh, FILE_CURRENT);
|
if (NT_SUCCESS (NtOpenFile (&h, FILE_READ_DATA, &attr, &io,
|
||||||
if ((cur != INVALID_SET_FILE_POINTER || GetLastError () == NO_ERROR)
|
FILE_SHARE_VALID_FLAGS, 0)))
|
||||||
&& ((!cur && !curhigh) || SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN)
|
{
|
||||||
!= INVALID_SET_FILE_POINTER))
|
LARGE_INTEGER off = { QuadPart:0LL };
|
||||||
{
|
char magic[3];
|
||||||
/* FIXME should we use /etc/magic ? */
|
|
||||||
magic[0] = magic[1] = magic[2] = '\0';
|
if (NT_SUCCESS (NtReadFile (h, NULL, NULL, NULL, &io, magic,
|
||||||
if (ReadFile (get_handle (), magic, 3, &done, NULL)
|
3, &off, NULL))
|
||||||
&& has_exec_chars (magic, done))
|
&& has_exec_chars (magic, io.Information))
|
||||||
{
|
{
|
||||||
pc.set_exec ();
|
pc.set_exec ();
|
||||||
buf->st_mode |= STD_XBITS;
|
buf->st_mode |= STD_XBITS;
|
||||||
}
|
}
|
||||||
SetFilePointer (get_handle (), cur, &curhigh, FILE_BEGIN);
|
NtClose (h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (pc.exec_state () == is_executable)
|
if (pc.exec_state () == is_executable)
|
||||||
buf->st_mode |= STD_XBITS;
|
buf->st_mode |= STD_XBITS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user