[ python-Bugs-1664966 ] crash in exec statement if uncode filename cannot be decoded

SourceForge.net noreply at sourceforge.net
Wed Feb 21 09:31:52 CET 2007


Bugs item #1664966, was opened at 2007-02-21 09:31
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1664966&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Stefan Schukat (sschukat)
Assigned to: Nobody/Anonymous (nobody)
Summary: crash in exec statement if uncode filename cannot be decoded

Initial Comment:
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;

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1664966&group_id=5470


More information about the Python-bugs-list mailing list