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

crashes when calling methods of an uninitialized zipimport.zipimporter object #75962

Closed
orenmn mannequin opened this issue Oct 13, 2017 · 3 comments
Closed

crashes when calling methods of an uninitialized zipimport.zipimporter object #75962

orenmn mannequin opened this issue Oct 13, 2017 · 3 comments
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@orenmn
Copy link
Mannequin

orenmn mannequin commented Oct 13, 2017

BPO 31781
Nosy @brettcannon, @orenmn
PRs
  • bpo-31781: Prevent crashes when calling methods of an uninitialized zipimport.zipimporter object #3986
  • 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 2017-10-20.20:43:37.214>
    created_at = <Date 2017-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 = <Date 2017-10-20.20:43:37.213>
    user = 'https://github.com/orenmn'

    bugs.python.org fields:

    activity = <Date 2017-10-20.20:43:37.213>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-10-20.20:43:37.214>
    closer = 'brett.cannon'
    components = ['Extension Modules']
    creation = <Date 2017-10-13.16:56:47.582>
    creator = 'Oren Milman'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31781
    keywords = ['patch']
    message_count = 3.0
    messages = ['304346', '304680', '304681']
    nosy_count = 2.0
    nosy_names = ['brett.cannon', 'Oren Milman']
    pr_nums = ['3986']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue31781'
    versions = ['Python 3.7']

    @orenmn
    Copy link
    Mannequin Author

    orenmn mannequin commented 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->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.

    @orenmn orenmn mannequin added 3.7 (EOL) end of life extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump labels Oct 13, 2017
    @brettcannon
    Copy link
    Member

    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
    Copy link
    Member

    As always, thanks for the fix, Oren!

    @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
    3.7 (EOL) end of life extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant