Skip to content

ZIP64 read-side defensiveness in bundle_locator + archive_io #65

Closed

Description

@jrosskopf

Follow-up from epic #40 / DESIGN_DECISIONS §9. ZIP64 was called out as
"out of scope" — config trees are kilobytes, but a defensive reader
should still handle the format gracefully.

Scope

Two surfaces to make ZIP64-defensive:

  1. `bundle_locator` — when a ZIP exceeds 4 GiB or has > 65535
    entries, the EOCD's cd_size / cd_offset / entry-count fields are
    set to sentinel `0xffff` / `0xffffffff` values and the real
    values live in the ZIP64 EOCD record (which sits before the
    ZIP64 EOCD locator, which sits before the regular EOCD). Currently
    `bundle_locator.cpp` rejects EOCDs with sentinel fields as
    "malformed".
  2. `archive_io` — libarchive already handles ZIP64 on read. Just
    verify our round-trip tests don't accidentally trip the boundary
    (a fixture with > 65535 entries would exercise this).

Practical bound: nobody will pack a > 4 GiB config tree, but a
hostile or accidentally-grown bundle should fail with "ZIP64 not
supported" instead of "no bundle present" (which is what happens
today and is misleading).

Acceptance

  • `bundle_locator` recognises ZIP64 sentinel fields and either:
    • reads the ZIP64 EOCD locator + record and returns a correct
      `BundleLocation`, OR
    • returns `nullopt` plus logs a single-line WARNING naming the
      ZIP64-vs-non-ZIP64 mismatch (lower-effort fallback).
  • 2 new test cases in `test/cpp/bundle_locator_test.cpp` with
    synthetic ZIP64-shaped fixtures.

References

  • DESIGN_DECISIONS §9 "Out of scope"
  • v26.05.23 release notes "Out of scope" section
  • ZIP APPNOTE.TXT § 4.5 (ZIP64 extra field) and § 4.3.16 (Zip64 EOCD)

Activity

  1. added
    enhancement
    on May 24, 2026
  2. jrosskopf commented on May 25, 2026

    @jrosskopf
    ContributorAuthor

    Scope-narrowing note after auditing current code:

    The defensive rejection part is already in place:

    • src/bundle_locator.cpp:89-94 performs range validation that implicitly rejects the ZIP64 sentinel values (cd_size > eocd_file_offset and cd_offset_arch > cd_file_offset both fail for 0xffffffff against any plausible flapi binary).
    • test/cpp/bundle_locator_test.cpp:122-150 ("rejects an EOCD with implausible fields") already exercises cd_size=0xffffffff / cd_offset_arch=0xffffffff and asserts REQUIRE_FALSE(loc.has_value()).
    • src/archive_io.cpp is libarchive-backed, so the read side handles ZIP64 transparently if it ever sees one.

    What is still missing — and is all that needs to ship to close this issue:

    1. A single-line WARN log in bundle_locator when sentinel fields are detected, naming "ZIP64-vs-non-ZIP64 mismatch" so the failure mode is no longer indistinguishable from "no bundle present" in operator logs.
    2. Renaming / re-titling the existing test case to explicitly mention ZIP64 (the test exists but is named generically), and adding a second test for sentinel entry-count (0xffff) to round out coverage of all three sentinel fields.

    The full ZIP64 EOCD locator (0x06064b50) + ZIP64 EOCD parser is not required. Config bundles will never approach 4 GiB; a clear log line at the rejection point is sufficient and matches the "lower-effort fallback" already called out in the acceptance criteria.

    Will tackle this after #63.

  3. added a commit that references this issue on May 25, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions