Fixed compilation error in xref.rs where u64 literal 0x5DEECE66D was used with u32 state, causing overflow. Changed state to u64 for proper Java Random algorithm behavior. The OCG /OCProperties parsing implementation was already complete and all tests pass. See notes/pdftract-2a6rk.md for verification. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
39 lines
1.3 KiB
Rust
39 lines
1.3 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,
|
|
};
|
|
|
|
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);
|
|
});
|