mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
SF #846659, fix bufsize violation and GNU longname/longlink extensions
This commit is contained in:
parent
13e50fe453
commit
0662f8a5ea
3 changed files with 96 additions and 2 deletions
|
@ -353,7 +353,6 @@ class _Stream:
|
|||
if self.mode == "w" and self.buf:
|
||||
if self.type != "tar":
|
||||
self.buf += self.cmp.flush()
|
||||
self.__write("") # Write remaining blocks to output
|
||||
self.fileobj.write(self.buf)
|
||||
self.buf = ""
|
||||
if self.type == "gz":
|
||||
|
@ -1775,6 +1774,8 @@ class TarFile(object):
|
|||
of the longname as size, followed by data blocks,
|
||||
which contain the longname as a null terminated string.
|
||||
"""
|
||||
name += NUL
|
||||
|
||||
tarinfo = TarInfo()
|
||||
tarinfo.name = "././@LongLink"
|
||||
tarinfo.type = type
|
||||
|
@ -1783,6 +1784,7 @@ class TarFile(object):
|
|||
|
||||
# write extended header
|
||||
self.fileobj.write(tarinfo.tobuf())
|
||||
self.offset += BLOCKSIZE
|
||||
# write name blocks
|
||||
self.fileobj.write(name)
|
||||
blocks, remainder = divmod(tarinfo.size, BLOCKSIZE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue