pdftract/fuzz/fuzz_targets/stream_decoder.rs
jedarden 2ba56d8186 feat(bf-3vo80): add UnmappedGlyphNamesConfig struct to build.rs
Added typed config struct for unmapped glyph names configuration:
- unmapped_glyph_names: Vec<String> - list of glyph names to skip
- description: Option<String> - optional documentation
- version: Option<String> - format version identifier

The struct represents the JSON structure from build/unmapped-glyph-names.json
and is ready for parsing implementation in follow-up beads.

Closes bf-3vo80. Verification: notes/bf-3vo80.md
2026-07-06 14:42:07 -04:00

40 lines
1.4 KiB
Rust

//! Fuzz target for the PDF stream decoder.
//!
//! This target tests INV-8 (no panic at public boundary) for the stream decoder.
//! Any panic indicates a stream decoder bug that must be fixed.
//!
//! This also tests EC-10 (decompression bomb) - the 512 MB limit must hold
//! under random predictor inputs.
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
use pdftract_core::parser::stream::{
FlateDecoder, ASCII85Decoder, ASCIIHexDecoder, LZWDecoder,
DEFAULT_MAX_DECOMPRESS_BYTES,
};
use pdftract_core::parser::StreamDecoder;
let mut counter = 0;
// Test FlateDecoder - must never panic
let _ = FlateDecoder.decode(data, None, &mut counter, DEFAULT_MAX_DECOMPRESS_BYTES);
// Test ASCII85Decoder - must never panic
let mut counter = 0;
let _ = ASCII85Decoder.decode(data, None, &mut counter, DEFAULT_MAX_DECOMPRESS_BYTES);
// Test ASCIIHexDecoder - must never panic
let mut counter = 0;
let _ = ASCIIHexDecoder.decode(data, None, &mut counter, DEFAULT_MAX_DECOMPRESS_BYTES);
// Test LZWDecoder - must never panic
let mut counter = 0;
let _ = LZWDecoder.decode(data, None, &mut counter, DEFAULT_MAX_DECOMPRESS_BYTES);
// Test with very low bomb limit (EC-10 decompression bomb)
let mut counter = 0;
let low_limit: u64 = 100;
let _ = FlateDecoder.decode(data, None, &mut counter, low_limit);
});