summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMatthias Klose <doko@ubuntu.com>2009-04-04 14:19:56 (GMT)
committerMatthias Klose <doko@ubuntu.com>2009-04-04 14:19:56 (GMT)
commita8da9e0e161ecf79703ae2a29f17619580166979 (patch)
treee9a3659eccb375c1108d2c14ab371755290aea6d /Python
parentee13a2ecf4410183cfecc256bcf9df3a2321659a (diff)
downloadcpython-a8da9e0e161ecf79703ae2a29f17619580166979.zip
cpython-a8da9e0e161ecf79703ae2a29f17619580166979.tar.gz
cpython-a8da9e0e161ecf79703ae2a29f17619580166979.tar.bz2
Merged revisions 71152 via svnmerge from
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. ........
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 38db290..977ee21 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -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)