Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue1159051] Handle corrupted gzip files with unexpected EOF

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Oct 25, 2007, 1:58 PM

Post #1 of 1 (146 views)
Permalink
[issue1159051] Handle corrupted gzip files with unexpected EOF

Wummel added the comment:

Here is a new test script that works with simple strings and no file
objects. It reproduces the error by cutting off the last two bytes of
the GZIP data.

The resulting struct error is due to the read() methods missing a check
that the requested amount of data is actually returned. In this case
read(4) returned 2 bytes instead of 4, and the struct raises an error.

I think the easiest way to handle this is to introduce a
read_save(fileobj, size) method that checks that the read() data is of
the requested size, else raise an error (perhaps an IOError?).

btw: you can remove the t.{gz,py} files, the test_gzip_error.py replaces
them.

Added file: http://bugs.python.org/file8610/test_gzip_error.py

_____________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue1159051>
_____________________________________
Attachments: test_gzip_error.py (0.40 KB)

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.