pdftract/notes/bf-1c4f6.md
jedarden 9093760e4c docs(bf-1c4f6): verify content fuzz harness build
- Verified cargo fuzz build content completes successfully
- Confirmed binary exists at fuzz/target/x86_64-unknown-linux-gnu/release/content (54MB)
- All acceptance criteria PASS
- Harness ready for fuzzing execution

Closes bf-1c4f6
2026-07-05 13:29:35 -04:00

2.5 KiB

Build content fuzz harness

Task: Build the content fuzz harness Bead: bf-1c4f6 Date: 2025-07-05

Work Completed

1. Added content target to fuzz/Cargo.toml

The content.rs fuzz target was not listed in fuzz/Cargo.toml. Added the following:

[[bin]]
name = "content"
path = "fuzz_targets/content.rs"

2. Fixed build script issue

The build script crates/pdftract-core/build.rs had an issue where the font fingerprint phf map was declared with [u8; 32] keys but was being built with string representations.

Fix:

  • Changed from byte array keys to hex string keys
  • Updated phf::Map<[u8; 32], ...> to phf::Map<&'static str, ...>
  • Modified the key generation to use hex strings directly
  • Added documentation explaining the hex string lookup approach

3. Updated fingerprint.rs for hex string lookups

Modified crates/pdftract-core/src/font/fingerprint.rs:

  • Added as_hex_string() method to FontFingerprint to convert [u8; 32] to hex string
  • Updated lookup_font_fingerprint() to use hex string lookup
  • Updated CachedFingerprint::from_font_program() to use hex string lookup
  • Updated CachedFingerprint::lookup() to use hex string lookup

4. Build verification

  • Command: cargo fuzz build content
  • Result: SUCCESS - 54MB binary produced
  • Binary location: /home/coding/pdftract/fuzz/target/x86_64-unknown-linux-gnu/release/content
  • Compilation errors: None
  • Compilation warnings: None (that would prevent execution)

Files Modified

  1. fuzz/Cargo.toml - Added content target
  2. crates/pdftract-core/build.rs - Fixed font fingerprint generation
  3. crates/pdftract-core/src/font/fingerprint.rs - Updated for hex string lookups

Acceptance Criteria

  • cargo fuzz build content completes successfully
  • No compilation errors or warnings that would prevent execution
  • Harness binary is built and available (54MB)

Final Verification (2026-07-05)

Re-verified the build is still working correctly:

  • Command: cargo fuzz build content
  • Result: BUILD SUCCESS
  • Binary verified: /home/coding/pdftract/fuzz/target/x86_64-unknown-linux-gnu/release/content (54MB, executable)
  • cargo-fuzz: Installed at /home/coding/.cargo/bin/cargo-fuzz

The harness remains ready for fuzzing execution.

Notes

The content fuzz harness tests INV-8 (no panic at public boundary) for the content stream interpreter. The harness runs the interpreter on both Normal and PositionHint processing modes with arbitrary input data, ensuring no panics occur on any input.