Skip to content

Commit 9021b78

Browse files
author
matthias.klose
committed
Merged revisions 71152 via svnmerge from
svn+ssh://[email protected]/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. ........ git-svn-id: http://svn.python.org/projects/python/branches/py3k@71154 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent a488dc8 commit 9021b78

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Core and Builtins
5959
- Issue #5392: when a very low recursion limit was set, the interpreter would
6060
abort with a fatal error after the recursion limit was hit twice.
6161

62+
- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
63+
short file names.
64+
6265
Library
6366
-------
6467

Python/pythonrun.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
11451145
{
11461146
PyObject *m, *d, *v;
11471147
const char *ext;
1148-
int set_file_name = 0, ret;
1148+
int set_file_name = 0, ret, len;
11491149

11501150
m = PyImport_AddModule("__main__");
11511151
if (m == NULL)
@@ -1163,7 +1163,8 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
11631163
set_file_name = 1;
11641164
Py_DECREF(f);
11651165
}
1166-
ext = filename + strlen(filename) - 4;
1166+
len = strlen(filename);
1167+
ext = filename + len - (len > 4 ? 4 : 0);
11671168
if (maybe_pyc_file(fp, filename, ext, closeit)) {
11681169
/* Try to run a pyc file. First, re-open in binary */
11691170
if (closeit)

0 commit comments

Comments
 (0)