Repository navigation
fix(handle-map): a section smaller than its own CRC is an error, not a panic - #231
Merged
Merged
Conversation
…a panic HandleMap::parse took a big-endian section size of 1 at face value and sliced the payload as [pos..pos-1], panicking. §23.1 counts the section's 2-byte CRC in its size (the list ends at size 2), so a size of 1 is malformed and now returns Error::SectionMap. Both fuzz targets that reach the parser found it within seconds once the nightly could fail; their crash inputs are committed as named seeds so every fuzz run replays them. Refs #187.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
2 tasks
DrunkOnJava
enabled auto-merge (squash)
October 26, 2026 09:43
DrunkOnJava
disabled auto-merge
October 26, 2026 09:44
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.
Summary
HandleMap::parsepanics on anAcDb:Handlessection whose big-endian size is 1: the size covers the section's own 2-byte CRC, sopos + section_size - 2puts the payload slice at[2..1]. A size below 2 is now anError::SectionMap, as the crate's malformed-input invariant requires. Found by the fuzz nightly once it could fail (#232); refs #187.Spec reference
§23.1 (AcDb:Handles, the object map; §23.2 says R2004+ is identical after decompression): each section is a big-endian short size, the handle/offset
MCpairs, then a 2-byte CRC, and the list repeats "until section size==2 (the last empty (except the CRC) section)", so the size counts the CRC. A size of 1 cannot hold it and is malformed. The parser's existing treatment of 0 as the end of the list is unchanged.Test plan
Both crash inputs the dispatched fuzz run found (run 40296541245) go through the real entry point,
dwg::handle_map::HandleMap::parse, from an out-of-tree binary:Both inputs are committed as named seeds (
fuzz/corpus/{section_map,handlemap_parse}/regress_section_size_1.bin), so every fuzz run replays them before mutating: the regression fixture #187 asks for, run through the fuzz targets themselves rather than a unit test.Local fuzzing with the fix,
cargo +nightly fuzz run <target> -- -max_total_time=60 -print_final_stats=1:Replaying each committed seed directory, new seeds included (
-runs=0):section_map5 files,handlemap_parse4 files, no crash.Real files:
cargo run --release --example coverage_report -- ../../samplesover the 19-file corpus is byte-identical before and after (TOTAL 3911 decoded, 525 skipped, 9 errored; "Handle-map self-check: 0 record(s) carry a handle that disagrees with the map"; "every handle-map entry resolved to a record").cargo fmt --all -- --checkSource-provenance declaration
By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:
CLEANROOM.md).Based on §23.1 and §23.2 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1) and the module's existing documentation of the section layout. No third-party code or comments were read.
Developer Certificate of Origin
By submitting this PR, I certify that the contribution complies with the Developer Certificate of Origin 1.1.