Skip to content

Mid-file NULs must not drop a CRC-valid suffix - #16

Merged
jaredLunde merged 2 commits into
beyondoss:mainfrom
paulocsanz:dst/b26-mid-nul-suffix
Aug 15, 2026
Merged

Mid-file NULs must not drop a CRC-valid suffix#16
jaredLunde merged 2 commits into
beyondoss:mainfrom
paulocsanz:dst/b26-mid-nul-suffix

Conversation

@paulocsanz

Copy link
Copy Markdown
Contributor

The B4 slack heuristic treats crc==0 && type==0 as a torn tail. Five NULs between two CRC-valid records look like that, so load() compact-rewrites the suffix away. Two commits: a test that fails on main, then the fix.

  • Trailing all-zero slack stays Truncated.
  • A zero hole in front of a non-zero suffix is InvalidFormat and does not rewrite the file.

git checkout HEAD~1 && cargo test --test dst_invariants mid_file_nuls fails; HEAD passes.

Five NULs at a record boundary are treated as a torn tail after the B4 slack heuristic, so load() rewrites a CRC-valid suffix away. This fails on current main.
crc==0 && type==0 is trailing slack only when the rest of the file is zeros. A hole in front of a CRC-valid suffix is InvalidFormat so load() does not rewrite the suffix away.
@jaredLunde
jaredLunde merged commit d409850 into beyondoss:main Aug 15, 2026
1 check passed
@jaredLunde jaredLunde mentioned this pull request Aug 16, 2026
jaredLunde added a commit that referenced this pull request Aug 16, 2026
* chore: bump to 0.7.3 — durability fixes since 0.7.2

Ship the four post-0.7.2 snapshot/watch fixes to crates.io:
- #13 snapshot load must not drop a durable tail
- #14 fsync parent directory after compact rename
- #15 refuse watch resume at u64::MAX (no wrap to 0)
- #16 mid-file NULs must not drop a CRC-valid suffix

Also refresh README install snippets from 0.5 → 0.7.

Co-authored-by: Jared Lunde <jared.lunde@gmail.com>

* chore: sync Cargo.lock package version to 0.7.3

Co-authored-by: Jared Lunde <jared.lunde@gmail.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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.

2 participants