[issue6669] TarFile.getmembers fails at struct.unpack: unpack requires a string argument of length 4

STINNER Victor report at bugs.python.org
Fri Nov 19 11:41:42 EST 2021


STINNER Victor <vstinner at python.org> added the comment:

File "/home/apy/ActivePython-2.6/lib/python2.6/gzip.py", line 24, in 
read32
    return struct.unpack("<I", input.read(4))[0]
error: unpack requires a string argument of length 4

The gzip.read32() function has been removed in Python 3:

commit 7c3922f44c226eac29a497648bbc3cc8702905a8
Author: Serhiy Storchaka <storchaka at gmail.com>
Date:   Tue Jan 22 17:01:59 2013 +0200

    Issue #1159051: GzipFile now raises EOFError when reading a corrupted file
    with truncated header or footer.
    Added tests for reading truncated gzip and bzip2 files.

---


  File "/home/apy/ActivePython-2.6/lib/python2.6/tarfile.py", line 
2307, in next
    self.fileobj.seek(self.offset)
  File "/home/apy/ActivePython-2.6/lib/python2.6/gzip.py", line 382, in 
seek
    self.read(1024)

Moreover, gzip.GzipFile().seek() no longer calls self.read(1024):

commit 2dbc6e6bce0a29757acddd8000d55f7c844295a2
Author: Antoine Pitrou <solipsis at pitrou.net>
Date:   Sat Apr 11 00:31:01 2015 +0200

    Issue #23529: Limit the size of decompressed data when reading from
    GzipFile, BZ2File or LZMAFile.  This defeats denial of service attacks
    using compressed bombs (i.e. compressed payloads which decompress to a huge
    size).
    
    Patch by Martin Panter and Nikolaus Rath.

IMO it's no longer possible to reproduce the gzip.error on gzip.GzipFile.seek(), so I close the issue as out of date.

----------
resolution:  -> out of date
stage: test needed -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue6669>
_______________________________________


More information about the Python-bugs-list mailing list