* Decode bzip2 pages in BitRock installers - #400
Merged
Merged
Conversation
Hawkynt
force-pushed
the
feat/bitrock-bzip2-cookfs-pages
branch
3 times, most recently
from
September 30, 2026 16:06
43653e3 to
1870474
Compare
InstallBuilder content reconstruction rejects cookfs pages with compression id 2 even though the embedded Cookfs format supports bz2 pages. Decode each page with the managed BZip2 stream and cover it with a multi-page byte-exact fixture. Creation is still unavailable because a valid installer requires the vendor runtime stub.
… bzip2 stream A CFS0002 bzip2 page is [u32 BE uncompressed size][bzip2 stream], but the reader handed the whole page to the bzip2 decoder, so a real page fails on its first four bytes. The fixture was built to the same wrong layout, which is why the round-trip test passed. Layout taken from the BSD-licensed cookfs 1.4 sources (CookfsReadPageBz2 / CookfsWritePageBz2, rung 1 as specification; no code copied). The reader now skips and checks the prefix: a page too short for it, or one whose stream decodes to a different length, is rejected. Fixtures follow the cookfs layout; the notes no longer claim bzip2 InstallBuilder samples were seen.
Hawkynt
force-pushed
the
feat/bitrock-bzip2-cookfs-pages
branch
from
September 30, 2026 18:03
4a4ac51 to
eef0eb5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
BitRock's cookfs (CFS0002) content reader handled stored and raw-DEFLATE pages and rejected compression id 2. This adds bzip2 pages.
In a CFS0002 bzip2 page the uncompressed size comes first, as a big-endian u32, followed by the bzip2 stream: libbz2's buffer API needs the output size, and the CFS0002 index doesn't record it. The first revision of this PR decoded from byte 0 and built its fixture the same way, so the test passed while real pages would fail. The reader now skips the prefix and checks it. A page too short for the prefix, or one that decodes to a different length, is rejected.
Sourcing
Rung 1 used as a specification: the BSD-licensed cookfs 1.x sources (
generic/pagesCompr.c,CookfsReadPageBz2/CookfsWritePageBz2, tag v1.4.0 of github.com/chpock/cookfs). No code was copied. Decoding uses the repository's managed BZip2 stream.Verification
dotnet test --filter Compression.Tests.BitRock: 15 passed.FORMAT-NOTES.mdsays so.BitRock stays read-only.