This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: OSError in TarFile.getmembers()
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, jvoisin
Priority: normal Keywords:

Created on 2019-12-16 13:07 by jvoisin, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
crash-462a00f845e737bff6df2fe6467fc7cdd4c39cd8e27ef1d3011ec68a9808ca8e jvoisin, 2019-12-16 13:07
Messages (2)
msg358485 - (view) Author: jvoisin (jvoisin) Date: 2019-12-16 13:07
The attached file produces the following stacktrace when opened via `tarfile.open` and iterated with `TarFile.getmembers`, on Python 3.7.5rc1:

```
$ cat tarrepro.py 
import tarfile
import sys

with tarfile.open(sys.argv[1]) as t:
  for member in t.getmembers():
    pass
```

```
$ python3 tarrepro.py crash-462a00f845e737bff6df2fe6467fc7cdd4c39cd8e27ef1d3011ec68a9808ca8e
Traceback (most recent call last):
  File "tarrepro.py", line 5, in <module>
    for member in t.getmembers():
  File "/usr/lib/python3.7/tarfile.py", line 1763, in getmembers
    self._load()        # all members, we first have to
  File "/usr/lib/python3.7/tarfile.py", line 2350, in _load
    tarinfo = self.next()
  File "/usr/lib/python3.7/tarfile.py", line 2281, in next
    self.fileobj.seek(self.offset - 1)
  File "/usr/lib/python3.7/gzip.py", line 368, in seek
    return self._buffer.seek(offset, whence)
  File "/usr/lib/python3.7/_compression.py", line 143, in seek
    data = self.read(min(io.DEFAULT_BUFFER_SIZE, offset))
  File "/usr/lib/python3.7/gzip.py", line 454, in read
    self._read_eof()
  File "/usr/lib/python3.7/gzip.py", line 501, in _read_eof
    hex(self._crc)))
OSError: CRC check failed 0x21e25017 != 0x7c839e8b
```

The OSError exception isn't documented as a possible exception when using TarFile.getmembers ( https://docs.python.org/3/library/tarfile.html ).
msg410990 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-19 23:52
Following Issue6584 it raises BadGzipFile.
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83246
2022-01-19 23:52:00iritkatrielsetnosy: + iritkatriel
messages: + msg410990
2019-12-16 13:07:11jvoisincreate