edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
lane aacgates: ec-aac cannot panic on malformed input, and passes clippy
Base: main at 95bc8a76.
Changes
crates/ec-aac/src/sbr_hf.rs:limiter_band_tablereturnsResult. The three unwraps (patch border,table[0],out.last()) are nowError::corrupterrors, propagated with?throughsbr_chain.rs,SbrChain::apply/apply_last(now returnResult), anddecode.rs.crates/ec-aac/src/sbr_payload.rs: the twoexpects on header and tables areok_or_else(Error::corrupt).crates/ec-aac/src/lib.rs:AacDecoder::decodeclamped the ADTS body slice (at + header_lencould passendon a truncated frame and panic). The plane copy intosamplesnow takes at mostframessamples, since merged planes can differ in length.- Clippy (
-D warnings, toolchain 1.98.1 on the servers) found a large set of issues that were not from this lane's changes:ec-dsp/src/lib.rsscale:chunks_exactreplaced bysplit_at_mut+chunks_mut.- 645
excessive_precisioninsbr_qmf_window.rsandsbr_qmf.rs: literals rewritten to the shortest decimal that round-trips to the same f64 (checked bit-for-bit in the script that did it,float(new) == float(old)). No value changed. chunks_exact(CONST)->as_chunks(sbr_chain.rs, test files).encode.rsquantise:#[allow(clippy::too_many_arguments)]with a reason line. It is on the encoder, not the decode path.- Test-only: unused
Resultfromapply(now.unwrap()), auseless_conversion, a collapsibleif, and aneedless_range_loop.
- New test
crates/ec-aac/tests/no_panic.rs:fixtures_truncated_and_corrupted_never_panic: the 6 committed ADTS fixtures infixtures/audio, 10 truncation points each and 50 single-byte corruptions each, seedSEED = 0x5EED_AAC0_0D15_EA5E. Each input is decoded incatch_unwind.random_adts_frames_never_panic: 500 frames, each with a valid 7-byte ADTS header (random sf_index 0..12, random channel_config 0..7, random length 7..606) followed by random payload.- Both pass. Note that the test verifies no panic only. It does not check that
decode returns
Errfor corrupted input.
Audit of the decode path (not exhaustive)
Grep for unwrap(), expect(, panic!, unreachable!, assert! in non-test code of
ec-aac. Remaining hits:
sbr_hf.rs,sbr_chain.rs,sbr_env.rs,sbr_payload.rs,sbr_bands.rs,config.rs,sbr_qmf.rs: everyunwrap/expect/asserthit left is inside#[cfg(test)].decode.rs:max_sfbis validated against the band table inparse_ics(line ~184), andsectionruns are checked againstmax_sfb. Thecb[g][sfb],sf[g][sfb]andgroup_len[g]indexing in the spectral and TNS paths relies on that validation.huffman.rsnodes[at][bit]: the tree is built from fixed codebooks and walked only with bits 0/1 from the reader.
Not every index expression in the 16k-line crate was reviewed by hand. The no-panic test is the evidence for input-reachable indexing, and it found nothing beyond the items above.
Verify
scripts/remote-run.sh aacgates -- cargo clippy -p ec-aac --all-targets -- -D warningsexit 0 (host a, run after the last source edit).EC_REQUIRE_FIXTURES=1 scripts/remote-run.sh aacgates --host a -- cargo test -p ec-aac --release --no-fail-fast- lib: 43 passed
- reelh_per_frame: 1 passed
- no_panic: 2 passed (new)
- obs_real_content: 1 passed
- oracle: 13 passed, 1 ignored (pre-existing
#[ignore]) - sbr_real_library: 16 passed
- exit 0
I did not run
mainseparately to diff test counts. Counts are compared against the pre-existing set only by the list above.
Environment notes (not code)
- The servers had no clippy component on the 1.98.1 toolchain. I ran
rustup component add clippyon both hosts. - The worktree's
fixturessymlink is absolute to the local machine. The sync copies it as is, so it dangles on the host. The run command re-points it to~/fixtures. - The HE-AAC fixtures (
.cache/heaac-fixtures/*.m4a, untracked, generated locally) were copied to host a in~/heaac-fixturesand staged into the lane by the run command. The lane sync deletes untracked directories, so they must be restaged per run. - Host b has no
~/fixtures/audio, so the run was pinned to--host a. tests/oracle.rswrites intostd::env::temp_dir()(i.e. /tmp). I did not change it.
Left
- Full manual audit of decode-path indexing (see above).
sbr_real_library.rsis over 5000 lines (orchestration limit). It is pre-existing, and I did not split it.- The no-panic test only checks for panics. Checking that each malformed input returns
Errwould need a stricter oracle.