You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
crashes when calling methods of an uninitialized zipimport.zipimporter object #75962
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=Noneclosed_at=<Date2017-10-20.20:43:37.214>created_at=<Date2017-10-13.16:56:47.582>labels= ['extension-modules', '3.7', 'type-crash']
title='crashes when calling methods of an uninitialized zipimport.zipimporter object'updated_at=<Date2017-10-20.20:43:37.213>user='https://github.com/orenmn'
The following code crashes:
import zipimport
zi = zipimport.zipimporter.__new__(zipimport.zipimporter)
zi.find_module('foo')
This is because get_module_info() (in Modules/zipimport.c) assumes that the
zipimporter object is initialized, so it assumes that self->prefix is not
NULL, and passes it to make_filename(), which crashes.
get_module_code() makes the same assumption, and zipimport_zipimporter_get_data_impl()
assumes that self->archive is not NULL, and passes it to PyUnicode_GET_LENGTH(),
which crashes.
Thus, every method of an uninitialized zipimporter object might crash.
New changeset db60a5b by Brett Cannon (Oren Milman) in branch 'master': bpo-31781: Prevent crashes when calling methods of an uninitialized zipimport.zipimporter object (GH-3986) db60a5b
Activity
orenmn commentedon Oct 13, 2017
The following code crashes:
import zipimport
zi = zipimport.zipimporter.__new__(zipimport.zipimporter)
zi.find_module('foo')
This is because get_module_info() (in Modules/zipimport.c) assumes that the
zipimporter object is initialized, so it assumes that
self->prefixis notNULL, and passes it to make_filename(), which crashes.
get_module_code() makes the same assumption, and zipimport_zipimporter_get_data_impl()
assumes that
self->archiveis not NULL, and passes it to PyUnicode_GET_LENGTH(),which crashes.
Thus, every method of an uninitialized zipimporter object might crash.
I would open a PR to fix this soon.
brettcannon commentedon Oct 20, 2017
New changeset db60a5b by Brett Cannon (Oren Milman) in branch 'master':
bpo-31781: Prevent crashes when calling methods of an uninitialized zipimport.zipimporter object (GH-3986)
db60a5b
brettcannon commentedon Oct 20, 2017
As always, thanks for the fix, Oren!