-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-107398: Fix tarfile stream mode exception when process the file with extra header data #126304
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
base: main
Are you sure you want to change the base?
Conversation
Misc/NEWS.d/next/Library/2024-11-02-02-02-31.gh-issue-107398.uUtA6Q.rst
Outdated
Show resolved
Hide resolved
@serhiy-storchaka PTAL when you got time( |
@serhiy-storchaka ping ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some refactoring, but except a struct.error
the new code looks equivalent to the old one. Could you please point what was changed in the behavior?
Lib/tarfile.py
Outdated
@@ -480,25 +480,27 @@ def _init_read_gz(self): | |||
# taken from gzip.GzipFile with some alterations | |||
if self.__read(2) != b"\037\213": | |||
raise ReadError("not a gzip file") | |||
if self.__read(1) != b"\010": | |||
(method, flag, _) = struct.unpack("<BBIxx", self.__read(8)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if it read less than 8 bytes?
Why use I
and then ignore the result?
xlen = ord(self.__read(1)) + 256 * ord(self.__read(1)) | ||
self.read(xlen) | ||
extra_len, = struct.unpack("<H", self.__read(2)) | ||
self.__read(extra_len) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the only relevant change is in this line.
…ile with extra header data
Co-authored-by: Kirill Podoprigora <[email protected]>
…UtA6Q.rst Co-authored-by: Kirill Podoprigora <[email protected]>
3bc23ce
to
5ffa30b
Compare
Hi @serhiy-storchaka Thanks for the review!
|
@serhiy-storchaka PTAL when you get time |
Fix #107398