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 johahn
Recipients
Date 2003-10-15.20:17:17
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=887415

Hi, I think I've found the correct solution to the problem 
(though I havn't actually tested it). Looking in tarfile.py...




358:   if self.type == "gz":


359:       self.fileobj.write(struct.pack("<l", self.crc))


360:       self.fileobj.write(struct.pack("<L", self.pos))




...shows that this error only occurs when using .gz extensions. 
Testing shows that this error occurs when self.pos > sys.
maxint*2+2, that is for files larger than 4Gb. This is not good 
since the newest tar and gzip versions can handle files larger 
than that.


   According to the gzip file format spec from www.wotsit.org, 
the last 4 bytes of a gzip file "contains the size of the original 
(uncompressed) input data modulo 2^32". All that has to be 
done is to perform this calculation prior to the call to struct.
pack. Here is my proposed fix:




358:   if self.type == "gz":


359:       self.fileobj.write(struct.pack("<l", self.crc))


360:       self.fileobj.write(struct.pack("<L", self.pos % 2**32)
)




   I also noted that in Jython 2.1 struct.pack('<L', sys.
maxint*2+2) does not raise an OverflowError but wraps around 
and returns '\x00\x00\x00\x00'. This results in the correct size 
calculation for gzip but to silent the overflow is probably not a 
good idea.




...johahn
History
Date User Action Args
2007-08-23 14:17:39adminlinkissue822668 messages
2007-08-23 14:17:39admincreate