mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
short file names.
This commit is contained in:
parent
29b36308a4
commit
edb5e1e09e
2 changed files with 6 additions and 2 deletions
|
@ -204,6 +204,9 @@ Core and Builtins
|
||||||
|
|
||||||
- The re.sub(), re.subn() and re.split() functions now accept a flags parameter.
|
- The re.sub(), re.subn() and re.split() functions now accept a flags parameter.
|
||||||
|
|
||||||
|
- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
|
||||||
|
short file names.
|
||||||
|
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
@ -898,7 +898,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
|
||||||
{
|
{
|
||||||
PyObject *m, *d, *v;
|
PyObject *m, *d, *v;
|
||||||
const char *ext;
|
const char *ext;
|
||||||
int set_file_name = 0, ret;
|
int set_file_name = 0, ret, len;
|
||||||
|
|
||||||
m = PyImport_AddModule("__main__");
|
m = PyImport_AddModule("__main__");
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
|
@ -915,7 +915,8 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
|
||||||
set_file_name = 1;
|
set_file_name = 1;
|
||||||
Py_DECREF(f);
|
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)) {
|
if (maybe_pyc_file(fp, filename, ext, closeit)) {
|
||||||
/* Try to run a pyc file. First, re-open in binary */
|
/* Try to run a pyc file. First, re-open in binary */
|
||||||
if (closeit)
|
if (closeit)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue