What might explain an “invalid stored block lengths” error?

空扰寡人 提交于 2019-12-12 11:01:52

问题


I am running a Rails (3.2.3) application with Ruby 1.9.3p194 on the basic Ubuntu lucid32 image in a Vagrant virtual box. The virtual box is running on Leopard, for what it's worth. I'm trying to use rubyzip in the application to decompress a zip archive - 2009_da_lmp.zip. Using code directly from examples in the rubyzip repository, I can confirm that I can list the archive file contents:

#f is the absolute path to 2009_da_lmp.zip (string)
Zip::ZipFile.open(f) { |zf| zf.entries[0] }  
 => 20090101_da_lmp.csv #that is indeed a file in the archive.

Using some more code from the examples in the repository, I try to get at an actual file in the archive:

Zip::ZipInputStream.open(f) { |zis|
  entry = zis.get_next_entry
  print "first line of '#{entry.name}' (#{entry.size} bytes: ) "
  puts "'#{zis.gets.chomp}'" }

=> first line of '20090101_da_lmp.csv' (826610 bytes: ) Zlib::DataError: 
   invalid stored block lengths #and a long stack trace I can provide 
                                #if that might help

The Mac OS decompression utility unzips the archive fine. I was wondering if it was some kind of encoding-related thing (my locale is set to en_US.UTF-8 because to make using PostgreSQL in dev less painful), but I don't know how to tell if that's the case. I can't find any information on what might cause this error.


回答1:


This is a typical error found when feeding random data to an inflater. In fact you will get this error about 1/4 of the time from random data (when the low three bits of the first byte are 000 or 001). So I would guess that the inflation is simply starting at the wrong byte for some reason.



来源:https://stackoverflow.com/questions/10577045/what-might-explain-an-invalid-stored-block-lengths-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!