mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 12:29:32 +08:00
* fhandler.cc (fhandler_disk_file::fstat): Always reset file position
to original value after checking for executable magic.
This commit is contained in:
parent
2c1296f856
commit
fa821be37b
@ -1,3 +1,8 @@
|
|||||||
|
Tue Jun 5 11:18:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* fhandler.cc (fhandler_disk_file::fstat): Always reset file position
|
||||||
|
to original value after checking for executable magic.
|
||||||
|
|
||||||
Mon Jun 4 16:21:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
Mon Jun 4 16:21:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* cygheap.h (cygheap_user::cygheap_user): Initialize token to
|
* cygheap.h (cygheap_user::cygheap_user): Initialize token to
|
||||||
|
@ -974,16 +974,23 @@ fhandler_disk_file::fstat (struct stat *buf)
|
|||||||
buf->st_mode |= S_IFREG;
|
buf->st_mode |= S_IFREG;
|
||||||
if (!dont_care_if_execable () && !get_execable_p ())
|
if (!dont_care_if_execable () && !get_execable_p ())
|
||||||
{
|
{
|
||||||
DWORD done;
|
DWORD cur, done;
|
||||||
char magic[3];
|
char magic[3];
|
||||||
/* FIXME should we use /etc/magic ? */
|
|
||||||
magic[0] = magic[1] = magic[2] = '\0';
|
/* First retrieve current position, set to beginning
|
||||||
if (ReadFile (get_handle (), magic, 3, &done, 0)
|
of file if not already there. */
|
||||||
&& done == 3)
|
cur = SetFilePointer (get_handle(), 0, NULL, FILE_CURRENT);
|
||||||
|
if (cur != INVALID_SET_FILE_POINTER &&
|
||||||
|
(!cur ||
|
||||||
|
SetFilePointer (get_handle(), 0, NULL, FILE_BEGIN)
|
||||||
|
!= INVALID_SET_FILE_POINTER))
|
||||||
{
|
{
|
||||||
if (has_exec_chars (magic, done))
|
/* FIXME should we use /etc/magic ? */
|
||||||
set_execable_p ();
|
magic[0] = magic[1] = magic[2] = '\0';
|
||||||
SetFilePointer (get_handle(), -(LONG) done, NULL, FILE_CURRENT);
|
if (ReadFile (get_handle (), magic, 3, &done, 0) &&
|
||||||
|
done == 3 && has_exec_chars (magic, done))
|
||||||
|
set_execable_p ();
|
||||||
|
SetFilePointer (get_handle(), cur, NULL, FILE_BEGIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (get_execable_p ())
|
if (get_execable_p ())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user