account for one-tuple return
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Wed, 29 Jan 2020 09:28:34 +0000 (10:28 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 1 Feb 2020 13:42:43 +0000 (14:42 +0100)
For some reason, feeding ``(0,)'' into os.read() as the length
argument fails with newer versions of python. Fix this by
unpacking the single element ``tuple'' before using it.

deltatar/tarfile.py

index fa771aa..21db045 100644 (file)
@@ -3589,7 +3589,7 @@ def inspect_gz_hdr (fd, off):
     if flags & GZ_FLAG_FTEXT: # created by some contrarian
         verdict = HDR_CAND_FISHY
     if flags & GZ_FLAG_FEXTRA:
-        xlen = struct.unpack ("<H", os.read (fd, 2))
+        xlen = struct.unpack ("<H", os.read (fd, 2))[0]
         xtra = os.read (fd, xlen)
         if len (xtra) != xlen: # eof inside header
             return HDR_CAND_JUNK, None