jxl-oxide decompresses brob (Brotli Exif/XMP) boxes into a buffer its AllocTracker
does not count, so a 54-byte box expanded to 64 MiB of XMP and a larger one can ask for
gigabytes before any pixel limit applies. decode now inflates every brob box under one
8 MiB budget per file, rewrites it as the plain box it wraps and drops boxes past the
budget, nested or broken ones. Files without a brob box are not copied.
For an animation frame that starts with an `ALPH` chunk, image-webp 0.2.4 decodes
the next chunk as VP8 whatever its FourCC, skips the size check it makes for frames
without alpha, and indexes the frame's buffers by the picture's own size. A picture
larger than its `ANMF` header, or a non-key frame (decoded as 0x0), panicked with
out-of-bounds indexing in `read_frame` and `fill_rgba`. image-webp also steps from one
frame to the next without the padding byte, so after an odd-sized `ANMF` chunk it
reads the next frame one byte early.
Before decoding, the container is walked for the first frame with alpha whose picture
is not a VP8 key frame of its header's size, and for the first odd-sized `ANMF` chunk.
That frame is refused like a damaged frame: `decode` (which reads frame 0) errors only
when it is the first, and `decode_webp_frames` keeps the frames before it with a
`Truncated` warning.
Found by fuzzing `decode_webp`; ported from storytold/photocraft#10473, which was
written before PhotoCraft's codecs moved here. The regression test panics without the
fix.
Co-authored-by: DJHoltkamp <4955429+DJHoltkamp@users.noreply.github.com>
take_out searched the whole rest of the document for the next picture and the next inline
object on every item, so a document with many of one kind and none (or few) of the other cost
items × size. It now keeps where the next of each is and searches for a kind again only once
it has been passed. The output is the same.
* image-codecs: PNG bounds its image on the IDAT data and reserves only what it can make (lightcraft#3912)
The plausibility check measured the stored samples against the whole file
length, so ancillary chunks lifted the bound, and the decoder then reserved
the whole expanded output up front. A 1-bit 20000x20000 image is 50 MB
stored but 400 MB to 1.6 GB once expanded to 8-bit grey, RGB or RGBA, so
about 60 KB of IDAT reserved gigabytes.
- Bound the stored samples on the bytes of the first IDAT run (1032:1 plus
1 MiB), not the file length.
- Reserve up front only what the IDAT data can inflate to; past that, grow
the buffer as rows decode, at most doubling and never past the full
output. A forged file fails on its first row; a real solid or sparse
1-bit image that is past the ratio once expanded still decodes.
- Interlaced images decode into the whole zero-filled output in one go,
so their expanded size is checked against the IDAT data.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc
* Fix Adam7 palette expansion bounds without allocating unvalidated output
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
Ported from storytold/lightcraft#672, whose decoder code now lives here.
Some CCD Coolpix bodies store two interlaced fields one after the other in
one tight 12-bit strip. For the measured bodies, in their measured legacy
layout (binary maker-note version 0.2.0.0, compression 1, one strip of
w*h*1.5 bytes), the fields are interleaved in the model's field order. The
E5700's CYGM mosaic becomes approximate linear RGB with fixed gains.
Masked columns are judged on the stored rows, so the header probe and the
full decode agree. Other files keep their stored rows.
Checked on 527 NEF/NRW samples: only the six E5400/E5700/E8400/E8800 files
(and four synthetic legacy-layout fixtures) change; the other 517 decode
bit-identically.
Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Reads the camera's white-balance presets as a Kelvin curve where the
decoders gave none:
- CR2 ColorData versions 1 to 12 (5-word records), version 10 at either
of its two layouts, picked by the Daylight record's 5200 K;
- CR3 ColorData versions 16-19, 32-34, 48 and 64-66;
- PEF maker note 0x0221 (entries of 53190 - K and the red/blue
multipliers);
- RW2/RWL/RAW tag 0x0027: the D55 and 3200 K studio tungsten
multipliers as a neutral pair with their chromaticities
(KelvinPresets::from_neutral_lights / neutral_lights).
Ported from storytold/lightcraft#2527.
Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A DNG tile's frame may hold at most twice the tile's samples and a Sony
quad tile's at most the tile's samples, with no 65,536-sample floor. The
floor let each of many tiny tiles decode and keep a frame far larger than
the tile budget counts (storytold/lightcraft#4024). A DNG tile also drops
the surplus capacity of a larger frame after the resize.
Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
One rustfmt call with every source root of the workspace is now longer
than a Windows command line may be (os error 206). rustfmt's result is
the same on every system; the Linux and macOS legs keep checking it.
The lint-command guard states the per-system stages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35e0352666 is the head of a deleted, squash-merged branch and is
reachable only through its pull request ref. d94a3593ad is main's head.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>