fix(font): validate Type1 decoding and cipher arithmetic - #1059
Merged
Merged
Conversation
andiwand
force-pushed
the
review/40-cff-parser-bounds
branch
from
October 5, 2026 12:02
f1911e3 to
7eedf8d
Compare
A PDF falls back to a substitute font when its embedded font is refused, so the page shows the wrong glyphs. As before this change, an unreadable number reads as zero, an unreadable /lenIV keeps the default of 4, and a charstring shorter than lenIV decrypts to nothing. A /lenIV below -1 and bad PFB framing still throw. The tests include the shared helper by its path, like the other test utilities. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gb1fLafqqzehpqPuU6uBfn
andiwand
force-pushed
the
review/41-type1-decoding
branch
from
October 5, 2026 12:17
8bf12c4 to
d25dc82
Compare
Type1, RTF, PDF and the document color parser each decoded hex digits on their own. util::string now has hex_digit, and the callers use it. RTF and PDF keep their throwing wrappers. Type1 uses the PostScript white space of ObjectParser::is_whitespace in place of its own copy. The Type1 hex loops use is_ascii_whitespace, and the eexec boundary has a named predicate that does not skip NUL or form feed. The document color check no longer depends on the locale. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gb1fLafqqzehpqPuU6uBfn
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.
🤖 Generated with Claude Code
Type1 cipher arithmetic promoted to signed int and overflowed even on a four-byte input. Compute the recurrence in uint32_t and share the two test encryption helpers. Preserve binary NUL bytes after eexec, support /lenIV -1 charstrings, reject truncated PFB segments, and reuse the shared locale-independent numeric parser. An unreadable number still reads as zero and a too-short charstring as empty, so one bad value does not refuse the font.
Validation: 46 targeted font tests and all 50 PDF corpus cases pass. Existing tests now cover three lenIV modes, a NUL-leading ciphertext and German numeric locale; one regression covers malformed numbers and PFB framing. A standalone UBSan reproducer fails on the previous cipher arithmetic and passes on the fix. Corpus warnings match the preceding branch.