pdfcraft/vendor/hayro
Brandon Thomas a5d830bf25 Never crash: predictor rows and stroke widths from the input can't exhaust memory
The second full nightly fuzz run on main found two more:
- hayro-syntax computed a Flate/LZW predictor row as columns × bits in
  wrapping arithmetic: /Columns 9223372036854775807 asked for 2^61 bytes and
  aborted on any machine. Row widths are now saturating usize (colors × bits
  also overflowed u8), a zero width is refused (it divided by zero), and a
  row longer than the data is not allocated (empty output, as before).
- hayro stroked /LW 9223372036854775807 as given, and stroke expansion
  allocated 10 GB. Widths are clamped to 4 × (canvas width + height) device
  pixels, which covers the same pixels.
Both findings now run in 8 MB. Synthetic regression test in render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 01:06:45 -04:00
..
examples more progress, roadmap, wip 2026-09-30 11:00:02 -04:00
src Never crash: predictor rows and stroke widths from the input can't exhaust memory 2026-10-05 01:06:45 -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 more progress, roadmap, wip 2026-09-30 11:00:02 -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

Crates.io Documentation

A crate for rendering PDF files.

This crate allows you to render pages of a PDF file into bitmaps. It is supposed to be relatively lightweight, since we do not have any dependencies on the GPU. All the rendering happens on the CPU.

The ultimate goal of this crate is to be a feature-complete and performant PDF rasterizer. With that said, we are currently still very far away from reaching that goal: So far, no effort has been put into performance optimizations, as we are still working on implementing missing features. However, this crate is currently the most comprehensive and feature-complete implementation of a PDF rasterizer in pure Rust. This claim is supported by the fact that we currently include over 1000 PDF files in our regression test suite. The majority of those have been scraped from the pdf.js and PDFBOX test suites and therefore represent a very large and diverse sample of PDF files.

As mentioned, there are still some serious limitations, including lack of support for encrypted/password-protected PDF files, blending and isolation, knockout groups as well as a range of smaller features such as color key masking. But you should be able to render the vast majority of PDF files without too many issues.

Safety

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

Examples

For usage examples, see the example in the GitHub repository.

Cargo features

This crate has one optional feature:

  • embed-fonts: See the description of hayro-interpret for more information.

License

Licensed under either of

at your option.