-
Notifications
You must be signed in to change notification settings - Fork 321
Closed
Description
Inputs
I have this weird zip archive which has 0x08074b50 header in the beginning of file:
hexdump invalid.zip
0000000 50 4b 07 08 50 4b 03 04 14 00 00 00 08 00 35 8e
0000010 87 4b d5 3c fa dc 0a 00 00 00 0f 00 00 00 08 00
Also, I have usual zip archive with exact same content, but with the normal header:
hexdump valid.zip
0000000 50 4b 03 04 14 00 00 00 08 00 35 8e 87 4b d5 3c
0000010 fa dc 0a 00 00 00 0f 00 00 00 08 00 1c 00 74 65
Issue
Zip::InputStream can't read invalid.zip file and silently returns nil, but Zip::File.open works just fine.
Source code
require 'zip'
Zip::InputStream.open(File.open('invalid.zip')) do |zip_io|
while (entry = zip_io.get_next_entry)
puts "InputStream, invalid.zip: #{zip_io.read}"
end
end
Zip::InputStream.open(File.open('valid.zip')) do |zip_io|
while (entry = zip_io.get_next_entry)
puts "InputStream, valid.zip: #{zip_io.read}"
end
end
Zip::File.open('invalid.zip') do |zip_file|
zip_file.each do |entry|
puts "File.open, invalid.zip: #{entry.get_input_stream.read}"
end
end
Zip::File.open('valid.zip') do |zip_file|
zip_file.each do |entry|
puts "File.open, valid.zip: #{entry.get_input_stream.read}"
end
endOutput:
InputStream, valid.zip: test test test
File.open, invalid.zip: test test test
File.open, valid.zip: test test test