]> granicus.if.org Git - python/commitdiff
Merged revisions 71152 via svnmerge from
authorMatthias Klose <doko@ubuntu.com>
Sat, 4 Apr 2009 14:19:56 +0000 (14:19 +0000)
committerMatthias Klose <doko@ubuntu.com>
Sat, 4 Apr 2009 14:19:56 +0000 (14:19 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71152 | matthias.klose | 2009-04-04 16:18:13 +0200 (Sa, 04 Apr 2009) | 3 lines

  - Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
    short file names.
........

Misc/NEWS
Python/pythonrun.c

index edb2f4b2b45da5cab34e12be335873bd13ce5e6a..09190a0b900f148bdb3b44663661dbbcd5369b99 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -89,6 +89,9 @@ Core and Builtins
 - Issue #4509: Various issues surrounding resize of bytearray objects to
   which there are buffer exports.
 
+- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
+  short file names.
+
 Library
 -------
 
index 38db290ea75cfe4606dc2d055372b327c4f8a4cc..977ee214d6b2d81fb328e7dcb81b42ce86abfcfd 100644 (file)
@@ -895,7 +895,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
 {
        PyObject *m, *d, *v;
        const char *ext;
-       int set_file_name = 0, ret;
+       int set_file_name = 0, ret, len;
 
        m = PyImport_AddModule("__main__");
        if (m == NULL)
@@ -912,7 +912,8 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
                set_file_name = 1;
                Py_DECREF(f);
        }
-       ext = filename + strlen(filename) - 4;
+       len = strlen(filename);
+       ext = filename + len - (len > 4 ? 4 : 0);
        if (maybe_pyc_file(fp, filename, ext, closeit)) {
                /* Try to run a pyc file. First, re-open in binary */
                if (closeit)