This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: crash in exec statement if uncode filename cannot be decoded
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jhylton Nosy List: jhylton, sschukat
Priority: normal Keywords:

Created on 2007-02-21 08:31 by sschukat, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg31299 - (view) Author: Stefan Schukat (sschukat) Date: 2007-02-21 08:31
In case the exec statement gets an open file with a unicode object in f->f_fp the return value of PyString_AsString is not checked for an error and therefore a NULL pointer is given to PyRun_File which then leads to a crash.

in ceval.c:
line 4171 ff 

FILE *fp = PyFile_AsFile(prog);
char *name = PyString_AsString(PyFile_Name(prog));
PyCompilerFlags cf;
cf.cf_flags = 0;
if (PyEval_MergeCompilerFlags(&cf))
    v = PyRun_FileFlags(fp, name, Py_file_input, 
                        globals, locals, &cf);
else
    v = PyRun_File(fp, name, Py_file_input, globals,
				       locals);

Name is NULL after conversion.

Patch would be:

FILE *fp = PyFile_AsFile(prog);
char *name = PyString_AsString(PyFile_Name(prog));
if(name == NULL)
     return -1;
PyCompilerFlags cf;
msg31300 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2007-02-25 15:58
Committed revision 53901.
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44598
2007-02-21 08:31:52sschukatcreate