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.

Author GeorgeNotaras
Recipients GeorgeNotaras
Date 2007-11-30.23:00:05
SpamBayes Score 0.041049726
Marked as misclassified No
Message-id <1196463606.39.0.826959093922.issue1531@psf.upfronthosting.co.za>
In-reply-to
Content
Assume the following situation:
- a healthy and uncompressed tar file: a.tar
- the metadata of the 1st and second files within the archive start at
positions 0 and 756 (realistic example values)

I partially damage 200 bytes of metadata (byte range 0-500) of the first
archived file:

f = open("a.tar", "rb+")
f.seek(100)
f.write("0"*200)

Now, I seek to the start of the 2nd archived file's metadata:

f.seek(756)

And I try to open the tar archive using tarfile.open() passing the
previous fileobject to it.

import tarfile
f_tar = tarfile.open(fileobj=f)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tarfile.py", line 1143, in open
    raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully

Wouldn't the expected behaviour be to successfully open the tar archive
at offset 756?

It seems that tarfile.open(fileobj=f) seeks to position 0 of the
fileobject f, fails to read the 1st archived file's metadata and throws
an exception.
History
Date User Action Args
2007-11-30 23:00:06GeorgeNotarassetspambayes_score: 0.0410497 -> 0.041049726
recipients: + GeorgeNotaras
2007-11-30 23:00:06GeorgeNotarassetspambayes_score: 0.0410497 -> 0.0410497
messageid: <1196463606.39.0.826959093922.issue1531@psf.upfronthosting.co.za>
2007-11-30 23:00:06GeorgeNotaraslinkissue1531 messages
2007-11-30 23:00:05GeorgeNotarascreate