Repository navigation
Closed
Labels
3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
Description
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 2021-09-29.10:58:55.030>
created_at = <Date 2019-12-13.16:00:48.662>
labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
title = 'zlib.error with tarfile.open'
updated_at = <Date 2021-09-29.10:58:55.028>
user = 'https://bugs.python.org/jvoisin'bugs.python.org fields:
activity = <Date 2021-09-29.10:58:55.028>
actor = 'lukasz.langa'
assignee = 'none'
closed = True
closed_date = <Date 2021-09-29.10:58:55.030>
closer = 'lukasz.langa'
components = ['Library (Lib)']
creation = <Date 2019-12-13.16:00:48.662>
creator = 'jvoisin'
dependencies = []
files = ['48774']
hgrepos = []
issue_num = 39039
keywords = ['patch']
message_count = 9.0
messages = ['358337', '358340', '358341', '399811', '399989', '402834', '402845', '402847', '402848']
nosy_count = 5.0
nosy_names = ['christian.heimes', 'ethan.furman', 'lukasz.langa', 'jvoisin', 'jack__d']
pr_nums = ['27766', '28613', '28614']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue39039'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
Activity
jvoisin commentedon Dec 13, 2019
The attached file produces the following stacktrace when opened via
tarfile.open, on Python 3.7.5rc1:tiran commentedon Dec 13, 2019
This file is also an invalid tar file:
gzip: stdin: invalid compressed data--format violated
tar: Child returned status 1
tar: Error is not recoverable: exiting now
jvoisin commentedon Dec 13, 2019
Sure, but as a user, I would expect a better exception, like ValueError or ReadError, along with an error message, instead of an unexpected zlib exception.
jdevries3133 commentedon Aug 18, 2021
@jvoisin I am able to reproduce the problem when I download your script, but I am having a hard time reproducing it by passing corrupt archives to
tarfile.open. How exactly was this file corrupted? I am trying to figure out if there are any similar implementation leaks / poor error messages in similar scenarios so I can do my best to patch them all.You can see the reproduction scripts I am using here to get a better idea of what I have been trying. Be forewarned, they are pretty gnarly!
https://gist.github.com/jdevries3133/acbb5ba2a19093d3bcc214733ef85e5a
jvoisin commentedon Aug 20, 2021
The file was created with a fuzzer, like the one described in https://dustri.org/b/fuzzing-python-in-python-and-doing-it-fast.html
ambv commentedon Sep 29, 2021
New changeset b6fe857 by Jack DeVries in branch 'main':
bpo-39039: tarfile raises descriptive exception from zlib.error (GH-27766)
b6fe857
ambv commentedon Sep 29, 2021
New changeset d6b69f2 by Łukasz Langa in branch '3.10':
[3.10] bpo-39039: tarfile raises descriptive exception from zlib.error (GH-27766) (GH-28613)
d6b69f2
ambv commentedon Sep 29, 2021
New changeset 7bff4d3 by Łukasz Langa in branch '3.9':
[3.9] bpo-39039: tarfile raises descriptive exception from zlib.error (GH-27766) (GH-28614)
7bff4d3
ambv commentedon Sep 29, 2021
Thanks for the fix, Jack! ✨ 🍰 ✨
Since the change translated
zlib.errortotarfile.ReadErrorwhich already has to be handled by user code, it's strictly decreasing the surface of necessary exception handling. So, treating this as a bug fix, I backported this to 3.9 and 3.10 as well.