pdfcraft/crates
jcl-bit ee06583523
Never crash: JBIG2 symbol dictionaries can't loop without end (#408)
`cargo xtask fuzz` found a 1.1 KB page whose JBIG2 image never finished
decoding (over two minutes, flat memory). It differs from a valid file by
one byte inside a symbol dictionary's arithmetic-coded data. Past the end
of its data the arithmetic decoder keeps returning values, and two loops
in symbol.rs only move on when those values make progress:

- Export runs (6.5.10): a run of length 0 doesn't advance, and the
  decoder returned 0 for ever. This was the fuzz finding.
- Height classes (6.5.5): a class whose first width is already the
  end-of-class marker decodes no symbol. A read-only sweep of the crate
  found this one. In a synthetic dictionary every class after the first
  symbol adds 13 to the height and decodes nothing, so it only fails
  when the height overflows u32, after 330 million classes (about five
  seconds per image, logged); a delta of 0 would never end.

The sweep found every other loop in hayro-jbig2 bounded by a symbol,
instance or pixel cap or by the end of the data. Bounded is not cheap
everywhere: refinement bitmaps in text regions and aggregate symbols
(up to 10,000 instances of up to 2^28 pixels each) are not changed
here.

Vendored hayro-jbig2 patch (3): a valid dictionary needs at most one
height class per new symbol and `2 x symbols + 1` export runs (they
alternate, so at most one zero-length run before each symbol's). Both
loops get that budget plus `EXTRA_EMPTY_STEPS` (1024), then fail the
dictionary as invalid. Encoders don't write empty steps back to back,
so the slack only tolerates oddities.

The fuzz finding now renders in 0.2 s. Synthetic regression test in
render: two dictionaries of a few arbitrary bytes each, found by
searching for streams that decode the same way (no corpus bytes). The
height-class one is drawn as twenty images so that it stalls well past
the 20 s timeout without the patch on any machine. Each case is red
with its own budget removed and green with it.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-10-09 09:22:21 -04:00
..
a11y Add image signatures with placement preview and resize controls (#335) 2026-10-08 16:36:26 -04:00
annot M5.7: keep natural image stamps upright on rotated pages (#473) 2026-10-09 09:21:31 -04:00
automation M5.7: keep natural image stamps upright on rotated pages (#473) 2026-10-09 09:21:31 -04:00
compare Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
content Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
cos M1: incremental saves are allocated once at their exact size (#402) 2026-10-09 09:16:01 -04:00
create M10.2: Create PDF from multiple files, edited as pages in the Organize grid (#361) 2026-10-08 17:42:13 -04:00
crypt Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
edit M7: pick a Japanese fallback face that has every glyph of the edited text (#384) (#472) 2026-10-09 09:14:04 -04:00
engine M5.7: keep natural image stamps upright on rotated pages (#473) 2026-10-09 09:21:31 -04:00
export Export to Word: detect tables of at most 63 columns, Word's limit (#479) (#483) 2026-10-09 09:14:34 -04:00
filters Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
fonts Never crash: CMap parsing can't panic, overflow or run away; tokens need no spaces (#495) 2026-10-09 09:14:13 -04:00
forms Run set-layer-visibility actions from links and push buttons (#292) 2026-10-08 11:27:10 -04:00
geom Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
js XFA: run FormCalc scripts (#301) 2026-10-08 13:06:33 -04:00
measure Measure: add distance, perimeter and area tools (#208) 2026-10-08 00:38:57 -04:00
model Phone photos follow EXIF orientation; image signatures stay upright on rotated pages (#434) (#485) 2026-10-09 09:14:55 -04:00
ocr Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
optimize M11: Optimize PDF and Reduce File Size run in the background with a progress bar (#370) 2026-10-08 18:46:34 -04:00
organize M5.7: keep natural image stamps upright on rotated pages (#473) 2026-10-09 09:21:31 -04:00
platform Platform: one save-staging helper for automation and the desktop app (#356) 2026-10-08 17:07:00 -04:00
preflight Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
print Security: print jobs, new digital IDs and the --control file no longer write through planted links (#338) 2026-10-08 16:04:48 -04:00
redact Redact: operators split across a page's content streams are redacted whole (#153) 2026-10-07 21:12:27 -04:00
render Never crash: JBIG2 symbol dictionaries can't loop without end (#408) 2026-10-09 09:22:21 -04:00
sign sign: read the .p12 files Windows writes (BER, not DER) (#453) 2026-10-09 09:15:32 -04:00
ui-egui Tests: one wgpu device compiles shaders at a time in fill_sign.rs (WARP ARM64 crash) (#395) 2026-10-09 09:21:57 -04:00
xfa XFA: run FormCalc scripts (#301) 2026-10-08 13:06:33 -04:00
xfdf FDF: replies and review status keep their parent comment (fixes #333) (#388) 2026-10-08 21:03:30 -04:00