mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-27 11:27:21 -06:00
* Format: admit the declared .pcraft canvas before loading it (#2935) A .pcraft manifest's canvas size was copied into the Document unchecked, so a few bytes of JSON could declare a 300000x300000 (or u32::MAX) canvas that the CPU reduction, thumbnails and display textures then work against in proportion to its area. The loader now refuses an empty canvas, a side above 300000 (Photoshop's PSB limit, as for PSD and file.new) and an area above 4 gigapixels, right after reading the manifest and before any tile or blob is decoded. Both limits are LoadOptions fields so trusted callers can change them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Format: admit every canvas the app can create on .pcraft load (#2935) The default pixel budget was 2^32 (65536 x 65536), but file.new, Canvas Size, Image Size with Resample off and PSB import all reach 300000 x 300000, so a document a user could create and save would not reopen. The default is now the full 300000^2 PSB canvas; the side limit still refuses anything larger, and callers handling untrusted files can lower either budget. Loading stays proportional to the file: layers keep only the tiles the bundle holds, so a huge declared canvas allocates nothing for its area. A compile-time assert in document_preset_cmds ties file.new's MAX_DIMENSION to the loader's defaults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
12 lines
454 B
Rust
12 lines
454 B
Rust
#![no_main]
|
|
//! Load arbitrary bytes as a .pcraft bundle with tight limits.
|
|
|
|
use libfuzzer_sys::fuzz_target;
|
|
use photocraft_format::{LoadOptions, load_from_bytes_with, read_manifest};
|
|
|
|
fuzz_target!(|data: &[u8]| {
|
|
let opts = LoadOptions { max_manifest_bytes: 1 << 20, max_blob_bytes: 16 << 20, max_total_bytes: 64 << 20, preserve_ids: false, ..Default::default() };
|
|
let _ = load_from_bytes_with(data, &opts);
|
|
let _ = read_manifest(data);
|
|
});
|