Skip to content

feat(self-packaging #65): ZIP64-sentinel WARN log in bundle_locator#68

Merged
jrosskopf merged 1 commit into
mainfrom
feature/gh-65-zip64-warning
May 25, 2026
Merged

feat(self-packaging #65): ZIP64-sentinel WARN log in bundle_locator#68
jrosskopf merged 1 commit into
mainfrom
feature/gh-65-zip64-warning

Conversation

@jrosskopf
Copy link
Copy Markdown
Contributor

Summary

Follow-up to the narrowing comment on #65. The defensive rejection of
ZIP64-sentinel-shaped EOCDs was already in place via the implicit
range checks at `src/bundle_locator.cpp:89-94`, but the failure
returned `nullopt` with no log line -- indistinguishable from
"no bundle present" in operator output.

This PR makes the ZIP64 case explicit:

  • Detects the sentinel values (`cd_size == 0xffffffff`,
    `cd_offset == 0xffffffff`, `entries_this == 0xffff`, or
    `entries_total == 0xffff`) inside the EOCD scan loop, after the
    disk-number sanity checks.
  • Emits a single-line `CROW_LOG_WARNING` naming the mismatch and the
    offending field values, so an operator who packed a > 4 GiB or

    65535-entry tree sees why their bundle isn't being recognised.

  • Returns `nullopt` early instead of falling through to the implicit
    range-check rejection.

Full ZIP64 EOCD locator (`0x06064b50`) + ZIP64 EOCD record parsing is
deliberately not implemented -- config bundles will never approach
4 GiB, and the WARN log gives operators enough signal to act.

Changes

  • `src/bundle_locator.cpp`: explicit ZIP64 sentinel check + WARN log
    • early `return std::nullopt`. Adds `<crow/logging.h>` include
      (other src/ files like `credential_manager.cpp` use the same
      header for the same purpose).
  • `test/cpp/bundle_locator_test.cpp`:

Test plan

  • `ctest` — 638 / 638 pass serially (5 → 6 bundle_locator
    tests; the new tag `[zip64]` picks up both ZIP64 cases)
  • `ctest -R "bundle_locator|zip64"` — 6 / 6 pass

Closes #65.

When a ZIP exceeds 4 GiB or 65535 entries, the EOCD's cd_size /
cd_offset / entry-count fields are pinned to 0xffffffff / 0xffff
and the real values live in a ZIP64 EOCD record that we don't
parse. The existing range-check rejection silently returned
nullopt for these, making the failure indistinguishable from
"no bundle present" in operator logs.

- bundle_locator: explicit ZIP64 sentinel check inside the EOCD
  scan loop; on match, emit a single-line CROW_LOG_WARNING naming
  the mismatch + offending field values, and return nullopt
- bundle_locator_test: rename the existing 0xffffffff fixture to
  call out the ZIP64 origin (issue #65); add a second case for the
  16-bit entry-count sentinel (0xffff) that previously slipped past
  the range checks since cd_size/cd_offset can still be plausible
@jrosskopf jrosskopf merged commit db5ff79 into main May 25, 2026
21 checks passed
@jrosskopf jrosskopf deleted the feature/gh-65-zip64-warning branch May 25, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZIP64 read-side defensiveness in bundle_locator + archive_io

1 participant