Skip to content

pdf: bound CFF endchar seac recursion so a cyclic font can't overflow the stack - #1477

Merged
bflatastic merged 1 commit into
storytold:mainfrom
midasmatterhorn:fix/cff-seac-recursion-depth
Oct 16, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
midasmatterhorn:fix/cff-seac-recursion-depth

Conversation

@midasmatterhorn

Copy link
Copy Markdown
Contributor

Importing a PDF or AI file that embeds a name-keyed CFF font whose accented glyph is an endchar seac pointing back at itself (directly or through a short cycle) recurses in Cff::outline until the stack overflows and the process aborts — a stack overflow is not catchable by the app's catch_unwind guard, so the whole app dies. The seac components are resolved with find(code).and_then(|g| self.outline(g)) and there is no depth limit, while the Type 1 interpreter one file over already bounds the same nesting with depth < 2.

This mirrors that guard: outline stays the entry point and routes the components through a private outline_depth(gid, depth), so a cyclic font is cut off instead of crashing. The regression test builds a w adx ady 65 65 endchar glyph that seacs onto itself using the existing write_test_cff fixture and asserts the outline comes back empty; before the fix the test process overflowed the stack (SIGABRT), after it passes.

Partially addresses #1446 (finding 1, CFF seac recursion). Targeted tests green locally; cargo xtask ci left to the project runners.

@bflatastic

Copy link
Copy Markdown
Member

Merged, thank you @midasmatterhorn! It landed on main with a batch of community PRs, after a full workspace build and test run on Windows: fmt, clippy -D warnings, all 3,463 tests, layers, assets and wasm.

@midasmatterhorn

Copy link
Copy Markdown
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants