Repository navigation
fix(doc): bound the LFO reservation by the records the table holds - #195
Open
sanghnkim-max wants to merge 1 commit into
Open
sanghnkim-max wants to merge 1 commit into
sanghnkim-max wants to merge 1 commit into
Conversation
parse_plf_lfo reserved Vec capacity straight from the PlfLfo's u32 count. A short table declaring 0xFFFF_FFFF asked for ~64 GB up front, which aborts the process wherever the allocator refuses it; the loop below already stops at the first missing record, so the reservation was the only unbounded step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
parse_plf_lfo(src/formats/doc/lists.rs) passes the PlfLfo'su32count straight toVec::with_capacity. A malformed.docwhose LFO table declares0xFFFF_FFFFrecords but holds none asks for about 64 GB (16-byte(u32, usize)elements) before the loop finds that the records are missing. Where the allocator refuses, Rust aborts the process instead of panicking, so a caller can't recover. The loop already stops at the first missing record, so the reservation was the only unbounded step.lfo_capacityclamps the reservation to(plf.len() - 4) / LFO_SIZE, the number of records that fit in the table.I checked the other
with_capacitycalls undersrc/. Each is bounded by au16/u8count or by the input's length; this was the only one taking a fullu32from the file.cargo test --workspace(297 passed),cargo clippy --all-targets -- -D warningsandcargo fmt --checkare all clean.🤖 Generated with Claude Code
Summary by cubic
Fixes a parser DoS where a malformed
.docwith an oversized LFO count could abort the process by requesting ~64 GB of memory up front.lfo_capacityclamps theVecreservation to the records the table can actually hold, matching the loop's existing stop-at-first-missing-record behavior.Written for commit 0692341. Summary will update on new commits.