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

zipfile: incorrect comment size will prevent extracting #54507

Closed
rep mannequin opened this issue Nov 3, 2010 · 2 comments
Closed

zipfile: incorrect comment size will prevent extracting #54507

rep mannequin opened this issue Nov 3, 2010 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@rep
Copy link
Mannequin

rep mannequin commented Nov 3, 2010

BPO 10298
Files
  • zipfile_recover_commentsize.patch
  • 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 2011-02-10.10:27:14.428>
    created_at = <Date 2010-11-03.14:00:37.713>
    labels = ['type-bug', 'library']
    title = 'zipfile: incorrect comment size will prevent extracting'
    updated_at = <Date 2011-02-10.10:27:14.427>
    user = 'https://bugs.python.org/rep'

    bugs.python.org fields:

    activity = <Date 2011-02-10.10:27:14.427>
    actor = 'rep'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-02-10.10:27:14.428>
    closer = 'rep'
    components = ['Library (Lib)']
    creation = <Date 2010-11-03.14:00:37.713>
    creator = 'rep'
    dependencies = []
    files = ['19477']
    hgrepos = []
    issue_num = 10298
    keywords = ['patch', 'needs review']
    message_count = 2.0
    messages = ['120326', '128278']
    nosy_count = 2.0
    nosy_names = ['alanmcintyre', 'rep']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue10298'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @rep
    Copy link
    Mannequin Author

    rep mannequin commented Nov 3, 2010

    Opening (and thus extracting) zip files with appended junk data is not possible with the way the current zipfile implementation checks validity. Basically the problem comes down to the comment size in the end-of-central-directory record being different from the size of the data following that record.

    Unix unzip and similar utilities handle that case by looking at the eocd-record and taking that as the correct value. Zip files with data appended to them will be extracted just fine with these tools.

    In python's zipfile the _EndRecData function will return None if the comment size does not match the record's value.

    The patch modifies this behaviour and takes only the portion of trailing data that the record specifies and due to that it does not raise BadZipfile exceptions if there's any junk data appended to a zip file.

    @rep rep mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 3, 2010
    @rep rep mannequin added stale Stale PR or inactive for long period of time. and removed stale Stale PR or inactive for long period of time. labels Feb 10, 2011
    @rep
    Copy link
    Mannequin Author

    rep mannequin commented Feb 10, 2011

    superseded by bpo-10694

    @rep rep mannequin closed this as completed Feb 10, 2011
    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants