summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMatthias Klose <doko@ubuntu.com>2009-04-04 14:18:13 (GMT)
committerMatthias Klose <doko@ubuntu.com>2009-04-04 14:18:13 (GMT)
commitedb5e1e09ecf92a4911c154217c9c979d827caeb (patch)
treea631a110772c6597d07f4c2366b3a7769ae99549 /Python/pythonrun.c
parent29b36308a40d6479f29b093f9decfa6f58fe31a1 (diff)
downloadcpython-edb5e1e09ecf92a4911c154217c9c979d827caeb.zip
cpython-edb5e1e09ecf92a4911c154217c9c979d827caeb.tar.gz
cpython-edb5e1e09ecf92a4911c154217c9c979d827caeb.tar.bz2
- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
short file names.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index b3866ce..8fc0ca1 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -898,7 +898,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)
@@ -915,7 +915,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)