Repository navigation
fix(font): bound CFF indices and dictionary operands - #1058
Merged
Merged
Conversation
andiwand
force-pushed
the
review/39-sfnt-serialization
branch
from
October 5, 2026 11:31
8bb6c57 to
53fde49
Compare
A PDF falls back to a substitute font when its embedded font is refused, so the page shows the wrong glyphs. These quirks now pass, as before this change: an INDEX whose first offset is not one, an unreadable real (it reads as zero), a reserved nibble, trailing DICT operands, a charset range past the glyphs (clipped), and FDSelect ranges that are out of order, past the glyphs or name an unknown FD (widths_for_glyph falls back). The bounds of INDEX, DICT and charstring reads stay strict. 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/40-cff-parser-bounds
branch
from
October 5, 2026 12:02
f1911e3 to
7eedf8d
Compare
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
CFF INDEX iteration could wrap at 65,535 entries, offsets could wrap or point outside the font, and dictionary/glyph reads could consume bytes from the next structure. Bound each view and validate ranges before expansion or integer conversion. Real operands use the shared locale-independent number parser. A quirk that only affects one glyph or operand does not refuse the font: an unreadable real reads as zero, a charset range past the glyphs is clipped, and FDSelect ranges out of order or with an unknown FD fall back to the Top DICT widths.
Validation: all 50 PDF corpus cases pass, alongside the font and Type1 suites. The corpus logs retain a missing-glyph font substitution and cross-reference recovery warning. Four focused regressions cover maximum INDEX counts, invalid ranges/operands, German numeric locale, and FDSelect coverage. Bounds follow Adobe CFF sections 4, 5, 13 and 19.