[New-bugs-announce] [issue31781] crashes when calling methods of an uninitialized zipimport.zipimporter object

Oren Milman report at bugs.python.org
Fri Oct 13 12:56:47 EDT 2017


New submission from Oren Milman <orenmn at gmail.com>:

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.


I would open a PR to fix this soon.

----------
components: Extension Modules
messages: 304346
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: crashes when calling methods of an uninitialized zipimport.zipimporter object
type: crash
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31781>
_______________________________________


More information about the New-bugs-announce mailing list