Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash in exec statement if uncode filename cannot be decoded #44598

Closed
sschukat mannequin opened this issue Feb 21, 2007 · 2 comments
Closed

crash in exec statement if uncode filename cannot be decoded #44598

sschukat mannequin opened this issue Feb 21, 2007 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@sschukat
Copy link
Mannequin

sschukat mannequin commented Feb 21, 2007

BPO 1664966

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2007-02-25.15:58:14.000>
created_at = <Date 2007-02-21.08:31:52.000>
labels = ['interpreter-core']
title = 'crash in exec statement if uncode filename cannot be decoded'
updated_at = <Date 2007-02-25.15:58:14.000>
user = 'https://bugs.python.org/sschukat'

bugs.python.org fields:

activity = <Date 2007-02-25.15:58:14.000>
actor = 'jhylton'
assignee = 'jhylton'
closed = True
closed_date = None
closer = None
components = ['Interpreter Core']
creation = <Date 2007-02-21.08:31:52.000>
creator = 'sschukat'
dependencies = []
files = []
hgrepos = []
issue_num = 1664966
keywords = []
message_count = 2.0
messages = ['31299', '31300']
nosy_count = 2.0
nosy_names = ['jhylton', 'sschukat']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1664966'
versions = ['Python 2.5']

@sschukat
Copy link
Mannequin Author

sschukat mannequin commented Feb 21, 2007

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;

@sschukat sschukat mannequin closed this as completed Feb 21, 2007
@sschukat sschukat mannequin assigned jhylton Feb 21, 2007
@sschukat sschukat mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Feb 21, 2007
@sschukat sschukat mannequin closed this as completed Feb 21, 2007
@sschukat sschukat mannequin assigned jhylton Feb 21, 2007
@sschukat sschukat mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Feb 21, 2007
@jhylton
Copy link
Mannequin

jhylton mannequin commented Feb 25, 2007

Committed revision 53901.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

0 participants