Repository navigation
pdf: checked_add for CFF Private DICT and Type 1 RD offsets from the file - #1482
Merged
bflatastic merged 2 commits intoOct 16, 2026
Merged
Conversation
# Conflicts: # crates/pdf/src/cff.rs
Member
|
Merged, thank you @midasmatterhorn! It landed on |
Contributor
Author
|
Thanks for sorting the test conflict and keeping both tests. Closing #1567 in favour of this one is right — it's a strict subset. |
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.
Three file-supplied
offset + lengthadditions in the font readers were still unchecked: the CFF Private DICT slice (d.get(off..off + size)), the Private DICT local-Subrs lookup (index(d, off + s)), and the Type 1 binary-item reader (priv_.get(q..q + n)) add numbers taken straight from the font file, where a huge real saturates tousize::MAXon cast. On debug/test builds (overflow checks on) a crafted font — a CFF top DICT with Private[1E300 1E300], or a Type 1/Subrsentry withRDlength18446744073709551615— makes the add overflow and panic the importer, violating the checked-arithmetic rule in AGENTS.md.All three sites now use
checked_addand fall back to the existing "empty Private DICT" / "skip the damaged item" behaviour. Regression tests build both fixtures and assert the font still parses (.notdefpresent); both failed with "attempt to add with overflow" before the fix.Partially addresses #1446 (finding 4, DICT offset overflow). Targeted tests green locally;
cargo xtask cileft to the project runners.