I've received the following bug report by email:
Hi, Thomas. I understand you are the maintainer of
the rubyzip library.
I've found a problem with decompressing some zip
files, returning:
c:/ruby/lib/ruby/gems/1.8/gems/rubyzip-
0.9.1/lib/zip/zip.rb:1213:in
`read_e_o_c_d': Zip consistency problem while reading
eocd structure
(Zip::ZipError)
The zip files in question are those of the ruby quiz
solutions.
Attached is a simple program to retrieve rubyquizzes
and decompress
their solutions from the net that exhibits the
behavior.
Just run it like:
download_quizzes.rb 1 1
For the record, the same zip file decompresses
properly using the
stand-alone gnu unzip utility.
PS. This is on windows, btw, using the latest
version of the rubyzip
gem on Ruby's One-Click Installer.
Anonymous
Logged In: YES
user_id=1222
I've investigated and it turns out that there is an extra
byte at the end of the file that rubyzip cannot account
for and therefore it throws an exception to flag the
problem. If I truncate the file to get rid of the last
byte rubyzip can handle the file. zipinfo verifies the
archive as valid, so we should be able to read it.
A further note: info-zip's unzip and zipinfo doesn't even
blink if you append a bunch of garbage to the end of a zip
archive. Should rubyzip be as forgiving?
I'm seeing this as well.
i threw in a ruby-debug call in read_e_o_c_d:
def read_e_o_c_d(io) #:nodoc:
buf = get_e_o_c_d(io)
debugger
@numberOfThisDisk = ZipEntry::read_zip_short(buf)
@numberOfDiskWithStartOfCDir = ZipEntry::read_zip_short(buf)
@totalNumberOfEntriesInCDirOnThisDisk = ZipEntry::read_zip_short(buf)
@size = ZipEntry::read_zip_short(buf)
@sizeInBytes = ZipEntry::read_zip_long(buf)
@cdirOffset = ZipEntry::read_zip_long(buf)
commentLength = ZipEntry::read_zip_short(buf)
@comment = buf.read(commentLength)
debugger
raise ZipError, "Zip consistency problem while reading eocd structure" unless buf.size == 0
end
irb: