Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-09-15 04:02:57 +0400
committerChristopher Faylor <me@cgf.cx>2005-09-15 04:02:57 +0400
commit59960f651d84055ca449f142e10097c273cb1a0c (patch)
tree4e1451bebe4483112aed321c4411838dde18822a /winsup
parentae37cc121868a4554b5118c8ad45f5493333b39e (diff)
* hookapi.cc (hook_or_detect_cygwin): Simplify very slightly.
* spawn.cc (av::fixup): Guard against problems reading an executable which does not match Microsoft's documentation about PE format.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/hookapi.cc2
-rw-r--r--winsup/cygwin/spawn.cc39
3 files changed, 36 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 693976766..dfb19cd57 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
2005-09-14 Christopher Faylor <cgf@timesys.com>
+ * hookapi.cc (hook_or_detect_cygwin): Simplify very slightly.
+ * spawn.cc (av::fixup): Guard against problems reading an executable
+ which does not match Microsoft's documentation about PE format.
+
+2005-09-14 Christopher Faylor <cgf@timesys.com>
+
* spawn.cc (av::error): Eliminate.
(av::av): Remove reference to error.
(av::replace0_maybe): Ditto.
diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc
index 08e257ba1..8539d2a7a 100644
--- a/winsup/cygwin/hookapi.cc
+++ b/winsup/cygwin/hookapi.cc
@@ -185,7 +185,7 @@ hook_or_detect_cygwin (const char *name, const void *fn)
function_hook fh;
fh.origfn = NULL;
fh.hookfn = fn;
- char *buf = fn ? NULL : (char *) alloca (strlen (name) + strlen ("64") + sizeof ("_"));
+ char *buf = fn ? NULL : (char *) alloca (strlen (name) + sizeof ("_64"));
int i;
// Iterate through each import descriptor, and redirect if appropriate
for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 14231dd5a..f82cce095 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -1020,6 +1020,15 @@ av::fixup (child_info_types chtype, const char *prog_arg, path_conv& real_path,
bool exeext = strcasematch (ext, ".exe");
if (exeext && real_path.iscygexec ())
return 0;
+ char *buf = NULL;
+ myfault efault;
+ if (efault.faulted ())
+ {
+ if (buf)
+ UnmapViewOfFile (buf);
+ real_path.set_cygexec (false);
+ return 0;
+ }
while (1)
{
HANDLE h = CreateFile (real_path, GENERIC_READ,
@@ -1033,22 +1042,32 @@ av::fixup (child_info_types chtype, const char *prog_arg, path_conv& real_path,
CloseHandle (h);
if (!hm)
goto err;
- char *buf = (char *) MapViewOfFile(hm, FILE_MAP_READ, 0, 0, 0);
+ buf = (char *) MapViewOfFile(hm, FILE_MAP_READ, 0, 0, 0);
CloseHandle (hm);
if (!buf)
goto err;
- if (buf[0] == 'M' && buf[1] == 'Z')
+ do
{
- unsigned off = (unsigned char) buf[0x18] | (((unsigned char) buf[0x19]) << 8);
- win16_exe = off < sizeof (IMAGE_DOS_HEADER);
- if (!win16_exe)
- real_path.set_cygexec (!!hook_or_detect_cygwin (buf, NULL));
- UnmapViewOfFile (buf);
- break;
- }
+ myfault efault;
+ if (efault.faulted ())
+ {
+ UnmapViewOfFile (buf);
+ real_path.set_cygexec (false);
+ break;
+ }
+ if (buf[0] == 'M' && buf[1] == 'Z')
+ {
+ unsigned off = (unsigned char) buf[0x18] | (((unsigned char) buf[0x19]) << 8);
+ win16_exe = off < sizeof (IMAGE_DOS_HEADER);
+ if (!win16_exe)
+ real_path.set_cygexec (!!hook_or_detect_cygwin (buf, NULL));
+ UnmapViewOfFile (buf);
+ break;
+ }
+ } while (0);
- debug_printf ("%s is a script", (char *) real_path);
+ debug_printf ("%s is possibly a script", (char *) real_path);
if (real_path.has_acls () && allow_ntsec
&& check_file_access (real_path, X_OK))