Skip to content

* ALZip: the real layout, ALZ bzip2 and ZipCrypto - #507

Open
Hawkynt wants to merge 7 commits into
mainfrom
feat/alzip-real
Open

Hawkynt wants to merge 7 commits into
mainfrom
feat/alzip-real

Conversation

@Hawkynt

@Hawkynt Hawkynt commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

ALZip read and wrote a layout of its own: a 4-byte header, wrong size-field widths, and size fields on directory entries. This replaces it with the real format, following unalz (MIT) and XADMaster's XADALZipParser (LGPL-2.1).

Reader

  • Real layout: the 8-byte header, BLZ\x01 local headers with 0/1/2/4/8-byte size fields, and the CLZ\x01 / CLZ\x02 end records. CP949 names.
  • Methods: stored, deflate, and ALZip's bzip2 variant (DLZ block markers, no CRCs).
  • ZipCrypto decryption; every member is CRC-checked.
  • Split archives and obfuscated deflate (method 3) are refused.

Writer

  • Stored or deflate members, optionally ZipCrypto-encrypted.
  • Edits use the verified rebuild. The in-place modifier, which wrote the invented layout, is removed.

Bzip2 change

  • Bzip2Decompressor's block-body decoding is factored out so AlzBzip2 can reuse it. The standard bzip2 path is unchanged and its tests pass.

Verification (AlZipReferenceTests plus the existing AlZipTests; provenance in Compression.Tests/AlZip/ReferenceVectors/README.md)

  • unalz's CC0 test archives, written by ALZip, extract exactly as unalz 0.2.1 extracts them. They cover stored, deflate, ALZ bzip2, ZipCrypto, CP949 names and directories.
  • unalz extracts three archives our writer produced: stored, deflate, and encrypted with a CP949 name.
  • The writer reproduces the two unencrypted ones byte for byte.
  • Malformed-input cases are covered: wrong or missing password, corrupt data caught by the CRC, unknown signature, not an ALZ file.

Integration update: depends on #537 for shared Intel HEX payload validation exposed by the required Linux suite. The dependency is integrated for CI and must land first; after it merges, the remaining diff is this PR's format change. The refreshed solution build and focused format, firmware, README and architecture checks pass.

Hawkynt and others added 7 commits October 23, 2026 14:52
Symptom: the reader and writer used a layout of their own - a 4-byte
header where ALZip writes 8, size-field widths read from the wrong
nibble (0x20 taken as 4 bytes, ALZip means 2), size fields expected on
directory entries that have none, and an invented end record. Real ALZip
archives misparsed after the first entry and our output was not ALZip.

Change, following unalz and XADMaster:
- "ALZ\x01" + version header, "BLZ\x01" local headers with 0/1/2/4/8
  byte size fields, "CLZ\x01"/"CLZ\x02" end records, split-marker and
  comment records recognised, CP949 names;
- methods: stored, deflate, and ALZip's bzip2 variant (no stream header,
  "DLZ\x01" block markers, no block CRC or randomised bit, "DLZ\x02" end;
  Bzip2Decompressor's block body is now reusable for it); obfuscated
  deflate (method 3) is refused;
- ZipCrypto decryption with the 12-byte header check, and encryption on
  create; every member verified against its CRC-32;
- the in-place modifier wrote the invented layout and is removed; edits
  go through the verified rebuild.

Evidence: unalz's CC0 test archives written by ALZip (stored, deflate,
ALZ bzip2, ZipCrypto, CP949 names, directories) extract exactly as unalz
0.2.1 extracts them; unalz extracts three archives our writer produced
(stored, deflate, encrypted, a CP949 name), and the writer reproduces
the unencrypted two byte for byte.

Sourcing: rung 1, alkegi/unalz (MIT) and XADMaster XADALZipParser
(LGPL-2.1), notice beside the code; fixtures CC0.
Retain ALZip and main reference resources together, keep main artwork, and regenerate Core and Archives API documentation for the ALZ bzip2 support and real-layout reader.

Verified: Release solution build, 148 focused format/codec/documentation/provenance tests passed with 3 tool-dependent skips, documentation generation completed without errors.
ALZip and NSIS both changed the bzip2 block decoder, while the maintenance table omitted supported wiping. Share the ALZip block-body entry point with both standard and NSIS framing and correct the table. Verified solution build, 197 focused tests covering both formats and bzip2, and three package documentation generators.
Adding a second named payload to Intel HEX could silently discard a file because the shared image builder kept only the first payload in filesystem enumeration order. Reject multiple non-metadata payloads, including an empty first payload, before any output is written. Tests verify creation refusal and byte-preserving add refusal.

Verified all three regressions fail before the fix and pass after it, 93 focused tests, 34280 required tests with 1582 skips and no failures, and three package documentation checks.
Bring the firmware payload validation fix onto current main after partitioned-disk support merged. Verified solution build, 299 focused tests and all three package documentation checks; the preceding required suite passed 34280 tests.
Integrate the independently tested Intel HEX payload-loss fix from PR #537 before rerunning the required suite for PR #507. Verified the solution build and focused format, firmware, documentation and architecture tests.
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.

1 participant