Skip to content

unzip silently drops data after the first gzip member #496

Open

Description

@gemshrine

BazaRb::Compress#unzip stops after the first member of a valid gzip stream. RFC 1952 defines a gzip file as a sequence of members placed one after another, but Zlib::GzipReader#each(4096) returns only the first member's data here.

Steps to reproduce:

  1. Create two gzip members containing first and second.
  2. Concatenate the compressed byte strings and pass them to unzip.

Actual result: unzip returns first and drops second. I reproduced this with the current implementation's Zlib::GzipReader#each(4096) call.

Expected result: decompressing a valid concatenated gzip stream returns firstsecond.

Impact: BazaRb#download calls unzip on a gzip response body and treats a 200 response as complete after writing that result. If the response contains multiple valid members, the downloaded file is silently truncated.

Technical evidence: lib/baza-rb/compress.rb iterates one Zlib::GzipReader without checking or processing subsequent members. The format is defined in RFC 1952, section 2.2.

Activity

  1. Vova4o commented on Oct 1, 2026

    @Vova4o

    Submitted #501 for review. unzip now reads all concatenated gzip members, preserving binary data and enforcing the existing uncompressed size limit across the combined output. Regression tests also cover empty members, the public download path, the exact limit, and corruption or truncation in later members. All six regressions fail on unchanged master and pass with the fix. The full local offline Rake build passes: 170 tests, 307 assertions, 99.13% coverage, standalone checks, RuboCop and YARD.

    All 12 CI checks pass, including the full Rake matrix on Ubuntu and macOS with Ruby 3.3 and 3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions