mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-18 23:12:15 +08:00
* path.h (has_exec_chars): Standard function for checking for executable magic
numbers. * path.cc (symlink_info::check): Use the above function. * fhandler.cc (fhandler_disk_file::open): Ditto.
This commit is contained in:
parent
772e2322bd
commit
b12796a06d
@ -1,3 +1,10 @@
|
|||||||
|
Tue Oct 31 18:12:56 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* path.h (has_exec_chars): Standard function for checking for
|
||||||
|
executable magic numbers.
|
||||||
|
* path.cc (symlink_info::check): Use the above function.
|
||||||
|
* fhandler.cc (fhandler_disk_file::open): Ditto.
|
||||||
|
|
||||||
Tue Oct 31 17:57:52 2000 Christopher Faylor <cgf@cygnus.com>
|
Tue Oct 31 17:57:52 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* path.cc (_readlink): Return ENOENT when file does not exist.
|
* path.cc (_readlink): Return ENOENT when file does not exist.
|
||||||
|
@ -1227,8 +1227,7 @@ fhandler_disk_file::open (path_conv& real_path, int flags, mode_t mode)
|
|||||||
/* FIXME should we use /etc/magic ? */
|
/* FIXME should we use /etc/magic ? */
|
||||||
magic[0] = magic[1] = magic[2] = '\0';
|
magic[0] = magic[1] = magic[2] = '\0';
|
||||||
ReadFile (get_handle (), magic, 3, &done, 0);
|
ReadFile (get_handle (), magic, 3, &done, 0);
|
||||||
if ((magic[0] == ':' && magic[1] == '\n') ||
|
if (has_exec_chars (magic, done))
|
||||||
(magic[0] == '#' && magic[1] == '!'))
|
|
||||||
real_path.set_exec ();
|
real_path.set_exec ();
|
||||||
if (!(flags & O_APPEND))
|
if (!(flags & O_APPEND))
|
||||||
SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
|
SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
|
||||||
|
@ -2319,11 +2319,12 @@ symlink_info::check (const char *in_path, const suffix_info *suffixes)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Not a symlink, see if executable. */
|
/* Not a symlink, see if executable. */
|
||||||
if (!(pflags & PATH_ALL_EXEC) && got >= 2 &&
|
if (!(pflags & PATH_ALL_EXEC) &&
|
||||||
((cookie_buf[0] == '#' && cookie_buf[1] == '!') ||
|
has_exec_chars (cookie_buf, got))
|
||||||
(cookie_buf[0] == ':' && cookie_buf[1] == '\n') ||
|
{
|
||||||
(cookie_buf[0] == 'M' && cookie_buf[1] == 'Z')))
|
debug_printf ("setting exec flag");
|
||||||
pflags |= PATH_EXEC;
|
pflags |= PATH_EXEC;
|
||||||
|
}
|
||||||
close_and_return:
|
close_and_return:
|
||||||
CloseHandle (h);
|
CloseHandle (h);
|
||||||
goto file_not_symlink;
|
goto file_not_symlink;
|
||||||
|
@ -122,6 +122,15 @@ const char * __stdcall find_exec (const char *name, path_conv& buf, const char *
|
|||||||
|
|
||||||
#define isdrive(s) (isalpha (*(s)) && (s)[1] == ':')
|
#define isdrive(s) (isalpha (*(s)) && (s)[1] == ':')
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
has_exec_chars (const char *buf, int len)
|
||||||
|
{
|
||||||
|
return len >= 2 &&
|
||||||
|
((buf[0] == '#' && buf[1] == '!') ||
|
||||||
|
(buf[0] == ':' && buf[1] == '\n') ||
|
||||||
|
(buf[0] == 'M' && buf[1] == 'Z'));
|
||||||
|
}
|
||||||
|
|
||||||
/* cwd cache stuff. */
|
/* cwd cache stuff. */
|
||||||
|
|
||||||
class muto;
|
class muto;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user