Skip to content

fix: check page 0 by CRC alone, not the data-page trailer rule - #30

Merged
Nathan-D-R merged 2 commits into
mainfrom
fix/superblock-trailer
Nov 1, 2026
Merged

Nathan-D-R merged 2 commits into
mainfrom
fix/superblock-trailer

Conversation

@Nathan-D-R

Copy link
Copy Markdown
Contributor

What changes

Page 0 is the superblock. Its 0x400..0xFFC holds the rolled engine fingerprint text (SPECIFICATION.md section 3.4), so 0xFF3 and 0xFF8..0xFFB are text, not a trailer. The reserved-zero trailer rule was applied to every page and failed page 0 on real QuickBooks files (opyright (c) at 0xFF0..0xFFB). The trailer was measured on pages 1..N only (section 4.1).

Page 0 now gets the CRC check but not the trailer rule. Pages 1..N keep both. SPECIFICATION.md sections 2 and 4.1 state the page-0 scope; CHANGELOG has an Unreleased "Fixed" entry.

API / behavior changes

  • Page::verify_trailer returns Ok(()) for page 0.
  • PageStore::page_verified, PageStore::verified_pages and the ApModel integrity checks (learn, deobfuscate, calibration page selection) no longer report Error::BadTrailer / WarningKind::BadTrailer for page 0. A bad CRC on page 0 still fails.
  • No signature changes.

Test

Synthetic bytes only. The first commit adds the tests and fails without the fix (BadTrailer { page: 0 }); the second makes them pass.

  • page 0 with a text tail and a valid CRC passes page_verified
  • page 0 with a corrupted CRC fails with BadCrc
  • a data page with 0xFF3 set fails with BadTrailer
  • ApModel's integrity check treats page 0 the same way

cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass. A real QuickBooks file was checked by hand (not committed): page_verified(0) is Ok and all 10773 pages verify.

Synthetic pages only. Page 0 carries rolled fingerprint text in
0x400..0xFFC (SPECIFICATION.md section 3.4), so 0xFF3 and 0xFF8..0xFFB
are text, while the trailer rule is for pages 1..N (section 4.1).

Seen failing before the fix: `cargo test -p opensqlany --lib` reports
2 failed (store::tests::page_zero_with_a_text_tail_passes_on_crc_alone
with `BadTrailer { page: 0 }` from page_verified, and
ap::tests::integrity_check_treats_page_zero_by_crc_alone, panicking on
the same BadTrailer from check_integrity). The bad-CRC and data-page
tests already pass and guard against over-relaxing the fix.
Page 0 is the superblock. Its 0x400..0xFFC holds the rolled fingerprint text (SPECIFICATION.md section 3.4), so 0xFF3 and 0xFF8..0xFFB are text and failed the reserved-zero trailer rule on real files. Page::verify_trailer now returns Ok for page 0; PageStore::page_verified, verified_pages and the ApModel integrity checks keep the CRC check on page 0 and both checks on pages 1..N. SPECIFICATION.md sections 2 and 4.1 state the page-0 scope.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
opensqlanywhere-docs e63a4bd Oct 31 2026, 05:14 PM

@Nathan-D-R
Nathan-D-R marked this pull request as ready for review November 1, 2026 16:26
@Nathan-D-R
Nathan-D-R merged commit ac3aef2 into main Nov 1, 2026
7 checks passed
@Nathan-D-R Nathan-D-R mentioned this pull request Nov 1, 2026
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