pdfcraft/vendor/hayro-interpret
Brandon Thomas 20842c72e3 Never crash: Type 1 font programs can't hang or overflow the stack (skrifa 0.47)
The nightly fuzz job found a Type 1 font that hung hayro: read-fonts 0.39
(through skrifa 0.42) looked ahead after every integer by parsing the next
token, which looked ahead again, recursing through a whole run of numbers.
A long run hung; 20,000 numbers overflowed the stack and aborted the
process. Upstream fixed the tokenizer; the vendored hayro-interpret now uses
skrifa 0.47 (read-fonts 0.44), with its one API change. The finding finishes
in 0.5 s. Synthetic regression test (it aborts with the old skrifa).
Corpus sweep: 0 regressions; text oracle unchanged (median F1 0.980, mean
0.866, every per-file score identical).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 10:47:39 -04:00
..
assets more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
examples more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
src Never crash: Type 1 font programs can't hang or overflow the stack (skrifa 0.47) 2026-10-05 10:47:39 -04:00
.cargo-ok more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
.cargo_vcs_info.json more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
Cargo.lock more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
Cargo.toml Never crash: Type 1 font programs can't hang or overflow the stack (skrifa 0.47) 2026-10-05 10:47:39 -04:00
Cargo.toml.orig more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
LICENSE-APACHE more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
LICENSE-MIT more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
README.md more progress, roadmap, wip 2026-09-30 11:00:02 -04:00

README.md

hayro-interpret

Crates.io Documentation

A crate for interpreting PDF files.

This crate provides an abstraction to interpret the content of a PDF file and render them into an abstract [Device], which clients can implement as needed. This allows you, for example, to render PDF files to bitmaps (which is what the hayro crate does), or other formats such as SVG.

It should be noted that this crate is still very much in development. Therefore it currently lacks pretty much any documentation on how to use it. It's current API also only really makes it useful for rendering to PNG or SVG, though this will be improved upon in the future.

Examples

See the examples folder on the GitHub repository. Apart from that, you can also consult the implementation of hayro and hayro-svg to get an idea on how to use this crate.

Safety

This crate forbids unsafe code via a crate-level attribute.

Cargo features

This crate has one optional feature:

  • embed-fonts: PDF processors are required to support 14 predefined fonts that do not need to be embedded into a PDF file. If you enable this feature, hayro will embed a (permissively-licensed) substitute for each font, so that you don't have to implement your custom font loading logic. This will add around ~240KB to your binary.

License

Licensed under either of

at your option.