edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
fuzztruehd: cargo-fuzz targets for ec-truehd
Goal: DONE.md shared gate 2, at least one cargo-fuzz target per untrusted entry point in ec-truehd. Base sha: 78ec1905 (main at worktree creation).
What changed
crates/ec-truehd/fuzz/: standalone cargo-fuzz crate (ec-truehd-fuzz, own[workspace], path dep on ec-truehd).decode_stream: whole input as a TrueHD/MLP elementary stream. Split into access units by their own length words (frame_length), fed to oneTrueHdDecoderso restart and filter state carries across units.parse_sync: major sync only. Raw input throughAccessUnitHeader::parse, then the same input wrapped in a valid AU header and TrueHD major sync word (the fixup, so mutations land on the sync fields and directory instead of the 4 sync bytes).seed.sh: no TrueHD fixtures in the repo, so seeds come from ffmpeg's truehd/mlp encoders (stereo, 2.1, 5.1 TrueHD and mono MLP, 1 s sine).parse_syncgets each stream's first access unit. ffmpeg's truehd encoder has no 7.1 layout, so 7.1 is not seeded..gitignorefortarget,corpus,artifacts,coverage.
- No checksum fixup in the targets: the restart CRC, substream parity and lossless check only increment
CheckStatscounters and never return an error, so mutated input is not rejected on those grounds. crates/ec-truehd/src/decode.rs, two fuzz-found panics, both fixed asErrors or guards:read_filterstored an out-of-range FIR/IIR order (9..15) before returningError::Corrupt. The decode loop keeps going after an error, so a later access unit with no parameter block indexed pastfir.state. Now validated before storing. Regression test:out_of_range_filter_order_is_refused_and_not_stored.recompute_sign_offsetshifted by a negativelsb_bitswhen the quant step was abovehuff_lsbs(it runs beforehuff_lsbsis re-read). Now leaves the offset at 0;read_blockalready refuses that case withError::Corrupt. Regression test:quant_step_above_huff_lsbs_does_not_shift_negatively.
crates/ec-truehd/src/encode.rsandtests/oracle.rs: six pre-existing clippy findings under the current toolchain (Iterator::find, twotype_complexity,is_multiple_of, a range loop overch_samples, and threechunks_exactwith constant size). Rewritten as iterator /as_chunksforms; the twotype_complexitysites carry#[allow]with a reason. No behaviour change intended.
Verify commands and results
Run locally, not through remote-run. Both server hosts reported slot busy through repeated 10-minute retry
windows (the first remote-run attempt on host a timed out after 600 s, the queued retry was stopped),
so the coordinator directed a local run with CARGO_TARGET_DIR=~/.cache/tgt-fuzztruehd TMPDIR=~/.cache/tmp-fuzztruehd.
cargo +nightly fuzz build --fuzz-dir crates/ec-truehd/fuzz: exit 0.cargo +nightly fuzz run decode_stream ... -- -max_total_time=120 -rss_limit_mb=3000 -timeout=10:- run 1: panic at
read_filter/filter_channel(index 8 of len 8). Crash found. - run 2 (after fix 1): panic at
recompute_sign_offset(shift overflow). Crash found. - run 3 (after fix 2): exit 0, 30653 runs in 121 s, no crash. Saved inputs (30 minimised + 1 raw) all replay clean.
- run 1: panic at
cargo +nightly fuzz run parse_sync ... (same flags):- run 1 and run 2: exit 0, 30668150 and 24623236 runs in 121 s, no crash.
- run 3 (after both fixes): exit 0, 42904387 runs in 121 s, no crash.
cargo clippy -p ec-truehd --all-targets -- -D warnings: exit 0 (after the encode.rs and oracle.rs fixes).cargo test -p ec-truehd --release: exit 0. lib 17 passed (includes the two new regression tests), library integration 1 passed, oracle 3 passed.cargo test -p ec-truehd(debug, overflow checks on): exit 0, 17 lib passed.
Crashes: 2 distinct (read_filter order OOB; recompute_sign_offset shift overflow). Each got one fix attempt, and both fixes held through the final smoke runs. No timeouts or OOM.
Left open
- The gate asks for 1 CPU-hour per target. Only 120 s smoke runs were done, so the gate is not met.
decode_streamruns slowly (about 30k exec/120 s) because each input is a full stream; the corpus is seeded from short ffmpeg streams only, not from real Blu-ray TrueHD.- No
ec-truehd/fuzz/Cargo.lockin this commit (matches fuzzaudio1). - ffmpeg's truehd encoder has no 7.1 layout, so 7.1 TrueHD is not in the seed corpus.
remote-run.shdid not run any command: both hosts stayed slot-busy, so this lane has no server verification.