Skip to content

"Invalid code lengths set" when extracting an xlsx from a buffer #466

@kalsan

Description

@kalsan

Hi there! This is a bug report that can be reproduced as follows:

  • a ZIP file contains several files in a subdirectory, one of them being an xlsx file
  • the ZIP is downloaded via Ruby Net::SFTP and stored in a buffer (using buff = sftp.file.open(path, 'r', &:read))
  • the buff is then given to Zip::File.open_buffer(buff)
  • attempt to extract or get_input_stream.read on the xlsx file from the ZIP results in:
Zip::DecompressionError: zlib error while inflating
from /app/vendor/bundle/gems/rubyzip-2.3.0/lib/zip/inflater.rb:41:in `rescue in produce_input'
Caused by Zlib::DataError: invalid stored block lengths
from /app/vendor/bundle/gems/rubyzip-2.3.0/lib/zip/inflater.rb:33:in `inflate'

Reproduced in rubyzip 2.0.0 and 2.3.0. Note that the error does not occur if open instead of open_buff is used.

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions