[issue46922] tarfile.TarFile.next() crashes on empty tar files

2022-03-04 Thread Ethan Furman


Change by Ethan Furman :


--
nosy: +ethan.furman

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46922] tarfile.TarFile.next() crashes on empty tar files

2022-03-04 Thread progval


New submission from progval :

Hi,

I found two related bugs when calling tarfile.TarFile.next() on an empty tar 
file, both when trying to seek when it should not:

import io
import tarfile

# Create a tarball with no member:
fd = io.BytesIO()
with tarfile.open(fileobj=fd, mode="w") as tf:
pass

# read in stream mode:
fd.seek(0)
with tarfile.open(fileobj=fd, mode="r|") as tf:
print(tf.next())   # tarfile.StreamError: seeking backwards is not allowed

# read in normal mode:
fd.seek(0)
with tarfile.open(fileobj=fd, mode="r") as tf:
print(tf.next())  # ValueError: negative seek value -1

--
components: Library (Lib)
messages: 414536
nosy: progval
priority: normal
severity: normal
status: open
title: tarfile.TarFile.next() crashes on empty tar files
versions: Python 3.10, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com