]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Allow scripts less that a page in length to be executed.
authorTom Hughes <tom@compton.nu>
Mon, 3 Oct 2005 09:06:36 +0000 (09:06 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 3 Oct 2005 09:06:36 +0000 (09:06 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4849

coregrind/m_ume.c

index 09f47d92d180ab244b57a2130a76c6f3e9bfa5c9..40091f722f29710a9b76f1851ca6be18e435afff 100644 (file)
@@ -794,8 +794,12 @@ static int do_exec_inner(const char *exe, struct exeinfo *info)
       return err;
    }
 
-   sres = VG_(pread)(fd, buf, sizeof(buf), 0);
-   if (sres.isError || sres.val != sizeof(buf)) {
+   bufsz = VG_(fsize)(fd);
+   if (bufsz > sizeof(buf))
+      bufsz = sizeof(buf);
+
+   sres = VG_(pread)(fd, buf, bufsz, 0);
+   if (sres.isError || sres.val != bufsz) {
       VG_(printf)("Can't read executable header: %s\n",
                   VG_(strerror)(sres.val));
       VG_(close)(fd);