Commit Graph
5 Commits
Author SHA1 Message Date
c65b7d93d6 Integration: file-size bound fits DWA EXR, RLE BMP and GIF screens (#8704)
The new plausibility check refused valid files that main opens:
- EXR DWAA/DWAB parts: they go past 2^16:1 (a flat 8192x4320 DWAB frame
  with 12 alpha-scheme mattes is 29,948 bytes, 75,629:1; run-length
  channels zlib-packed on top reach about 132,000:1). DWA parts now get
  2^18:1, so a header of a few hundred bytes can ask for about 100 MB,
  not gigabytes.
- BMP RLE8/RLE4: end-of-line, end-of-bitmap and delta escapes leave pixels
  unwritten, so no ratio bounds a valid file (an EOB-only 4000x4000 RLE8 is
  1,080 bytes). Skipped like HDR.
- GIF: the decoder's size is the logical screen, which needs no data (a
  4000x4000 screen with a 1x1 frame is 35 bytes). The first frame must be
  backed, and the screen only past 256 MiB, so a 35-byte GIF still can't
  declare a 30000x30000 screen.
The declared-size products saturate: a Radiance header of 2^31 x 2^31
read without limits overflowed u64 in debug builds.

Co-authored-by: FinnNk <1424666+FinnNk@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:46:11 +01:00
Finn NewickandClaude Opus 5.5 07f91c6d37 fix(codecs): one JPEG frame-size guard for truncated and complete files
main gained a guard refusing truncated scans too short for their
frame; this branch's own header check refused those files first with a
different error. Drop it and widen main's guard instead: a complete
file is measured on its length (the scan walk may stop early on odd
marker layouts), a truncated one on its scan data as before. A frame
needs at least a one-bit DC code per 8x8 block, so 2048 pixels a byte
stays far above any real JPEG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 23:57:23 +01:00
Finn NewickandClaude Opus 5.5 dde976d03c Merge upstream main into fix/codec-plausible-dims
Main's own PCX and XPM preflight (827d949af) replaces this branch's PCX
ratio check and XPM row check; the PCX test now expects main's refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 00:45:05 +01:00
Finn NewickandClaude Opus 5.5 fb04b02893 fix(codecs): check header dimensions against the file size before allocating
JPEG, the image-crate formats (GIF, BMP, TGA, ICO, QOI, HDR), PCX, XPM and
flat EXR sized their output buffers from header dimensions, checked only
against the absolute limits. A few-KB file could declare ~3 GB and the
decoder allocated it before finding the data missing (on wasm that aborts
the tab). Each now refuses, before allocating, a file too small to hold
the declared image at that format's best compression ratio, the guard
PNG, WebP and IFF already use. XPM checks its text rows up front.

Fixes #8597

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 22:26:11 +01:00
aiongg a6428d3dfb Build each crate's integration tests as one binary
Every tests/*.rs file is its own executable that links the whole crate
graph. Move each crate's test files into tests/it/ as modules of one
tests/it/main.rs; helper modules under tests/common move with them.

These keep their own binary (own process):
- engine panic_hunt: a process-wide panic hook counts every panic.
- engine text_gamma: changes the process-wide text gamma.
- engine smart_filter_stages, mask_cache_purge: assert on global caches.
- codecs pnm_peak_memory: reads the process's peak RSS.
- photocraft mac_menu_appkit: harness = false.
2026-10-22 16:55:34 +00:00