Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,17 +1292,22 @@ def _proc_pax(self, tarfile):
if self.type in (XHDTYPE, SOLARIS_XHDTYPE):
# Patch the TarInfo object with the extended header info.
next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
next.offset = self.offset

if "size" in pax_headers:
# If the extended header replaces the size field,
# we need to recalculate the offset where the next
# header starts.
offset = next.offset_data
offset = next.offset + BLOCKSIZE
if next.isreg() or next.type not in SUPPORTED_TYPES:
offset += next._block(next.size)
try:
size = PAX_NUMBER_FIELDS["size"](pax_headers["size"])
except ValueError:
size = 0
offset += next._block(size)
tarfile.offset = offset

next.offset = self.offset

return next

def _proc_gnusparse_00(self, next, pax_headers, buf):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Compute next header offset using pax size for sparse file instead of the
sparse real size (expended size).