Skip to content

Unzip file corruption #45

@hasufell

Description

@hasufell

Problem

I have a file corruption when unpacking a zip archive via the haskell libarchive bindings.

This affects ghcup: https://github.com/haskell/ghcup-hs/actions/runs/23145451625/job/67236969726?pr=1313#step:6:753

Things I've already discovered:

  • it happens on both windows and linux
  • it happens with the new 3.8.5/3.8.6 C library versions (which we use since 3.0.5.0), but not with 3.7.1 (which was used in 3.0.4.2)
  • the corrupted file's hash is stable, it doesn't randomly change
  • it doesn't happen when I use only the C library (via bsdunzip) without going through the Haskell bindings

My suspicion is that the C API must have changed slightly maybe, but I'm not sure.

Reproducer

Manual:

$ wget https://downloads.haskell.org/ghcup/unofficial-bindists/cabal/3.14.2.0/cabal-install-3.14.2.0-x86_64-mingw64.zip
$ cabal run -f-no-exe archive -- --extract -f cabal-install-3.14.2.0-x86_64-mingw64.zip
$ sha256sum cabal.exe
$ rm cabal.exe plan.json
$ unzip cabal-install-3.14.2.0-x86_64-mingw64.zip
$ sha256sum cabal.exe

Or check out this PR and run the tests: #44

The checksum that I get via libarchive is 1971f345d120d4c5721a8394cc7a44cc609154cfe4727f1938efdfcd134d6e54.

The checksum that I get via normal unzip is 4b43a1d5a6bba82bc703db6b8ebd98b0712b2269ca7799a0f0bf6df5b5c683d0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions