mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-12 10:03:51 +00:00
PhotoCraft's `photocraft-psd` crate (crates/psd at storytold/photocraft 63b641b55e54bf8f5c83efd977fdb16a2c255431) as `craft-psd`: the lossless PSD/PSB model, reader, writer and builder, descriptors, the Photoshop resource files that share its primitives (.abr, .asl, .aco, .act, .ase, .grd, .pat, .atn, .csh, .shc) and the Photoshop blocks of a layered TIFF. The crate had no dependency on any other PhotoCraft crate. Code is unchanged apart from the crate name, craft-libs' rustfmt width, comments that named other PhotoCraft crates, issue references (now `photocraft#N`), and the corpus tests' directory (`CRAFT_PSD_CORPUS` or `corpus/` at the workspace root). Tests, proptests, fuzz targets and fixtures move with it. Part of #778, #786.
19 lines
783 B
Rust
19 lines
783 B
Rust
//! Fuzz the layered-TIFF tag parsers (37724 image source data in either byte order, and 34377
|
|
//! image resources), and the byte-order transcoder on anything that parses.
|
|
#![no_main]
|
|
|
|
use libfuzzer_sys::fuzz_target;
|
|
use craft_psd::tiff::{ByteOrder, ImageSourceData, resources_from_bytes};
|
|
|
|
fuzz_target!(|data: &[u8]| {
|
|
let _ = resources_from_bytes(data);
|
|
let Ok((d, _)) = ImageSourceData::from_bytes(data) else { return };
|
|
// Whatever parsed must write in both orders, and each output must parse again.
|
|
for order in [ByteOrder::Big, ByteOrder::Little] {
|
|
if let Ok((out, _)) = d.to_bytes(order) {
|
|
let (again, _) = ImageSourceData::from_bytes(&out).expect("re-parse of written data");
|
|
let _ = again.to_bytes(order);
|
|
}
|
|
}
|
|
});
|