rapid7/metasploit-framework — pull request #1755 by xard4s (2013-04-23 20:04:33+00:00)
Title: Fix trailing whitespace in zip files

Fixes an issue that prevents zip files from being opened.
"ZipError: Zip consistency problem..." gets raised because of trailing whitespace in eocd structure. The applied fixes are from the official rubyzip repo https://github.com/aussiegeek/rubyzip/issues/53 .
I tested it with a "corrupt" file:

before

$ irb
1.9.3-p385 :002 > require 'zip/zip'
=> true
1.9.3-p385 :003 > zf = Zip::ZipFile.open("/tmp/tUzkTQ.zip")
Zip::ZipError: Zip consistency problem while reading eocd structure
from /home/xardas/git/metasploit-framework/lib/zip/zip.rb:1262:in `read_e_o_c_d'
from /home/xardas/git/metasploit-framework/lib/zip/zip.rb:1278:in `read_from_stream'
from /home/xardas/git/metasploit-framework/lib/zip/zip.rb:1410:in `block in initialize'
from /home/xardas/git/metasploit-framework/lib/zip/zip.rb:1410:in `open'
from /home/xardas/git/metasploit-framework/lib/zip/zip.rb:1410:in `initialize'
from /home/xardas/git/metasploit-framework/lib/zip/zip.rb:1428:in `new'
from /home/xardas/git/metasploit-framework/lib/zip/zip.rb:1428:in `open'
from (irb):3
from /home/xardas/.rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in main

after

$ irb
1.9.3-p385 :002 > require 'zip/zip'
=> true
1.9.3-p385 :003 > zf = Zip::ZipFile.open("/tmp/tUzkTQ.zip")
=> /tmp/tUzkTQ.zip