Audit fixes + DVD support foundation (IFO, PS demux, MPEG-2, CSS crack)

Audit fixes (14 critical, 22 warnings):
- UDF: bounds checks on all ICB/FID parsing from disc data
- SCSI Linux: saturating_sub on residual, CDB length guard, buffer size guard
- SCSI macOS: SCSITaskStatus u32 (was u8 — stack corruption)
- AACS: EC mod_inv returns infinity instead of panic, key reduced mod n
- AACS: do_handshake tries all host certs (was returning on first failure)
- H.264: bounds check on SPS < 4 bytes
- ContentReader: error on missing unit key (was zero-fill)
- KEYDB: flat redirect loop (was recursive), 100MB response limit, Windows HOME fallback
- ISO writer: AVDP extent order, partition length, allocation cap
- Network: removed TCP_NODELAY on bulk stream
- MKV: guard on u64::MAX seek
- disc.rs: saturating_sub on extent offset, simplified dead region code
- cargo fmt (610 violations), cargo clippy --fix (55 auto-fixes)

DVD support (new files):
- src/ifo.rs — IFO parser (VIDEO_TS.IFO, VTS_XX_0.IFO, PGC chains, cells, streams) — 13 tests
- src/mux/ps.rs — MPEG-2 Program Stream demuxer (pack headers, PES, private stream 1) — 12 tests
- src/mux/codec/mpeg2.rs — MPEG-2 video parser (sequence headers, I-frame detection) — 15 tests
- src/css/crack.rs — split-attack algorithm (LFSR cipher needs verification — test ignored)

226 tests total (was 186), 1 ignored (CSS crack needs cipher verification).
This commit is contained in:
MattJackson
2026-04-11 16:52:22 +00:00
parent 6de4ee4b5c
commit 01235ff347
57 changed files with 6189 additions and 1519 deletions
+17 -5
View File
@@ -1,9 +1,9 @@
//! UDF parser tests using a MockSectorReader.
use std::collections::HashMap;
use libfreemkv::error::Result;
use libfreemkv::sector::SectorReader;
use libfreemkv::udf;
use std::collections::HashMap;
const SECTOR_SIZE: usize = 2048;
@@ -15,12 +15,18 @@ struct MockSectorReader {
impl MockSectorReader {
fn new() -> Self {
Self { sectors: HashMap::new() }
Self {
sectors: HashMap::new(),
}
}
/// Write a full 2048-byte sector at the given LBA.
fn set_sector(&mut self, lba: u32, data: Vec<u8>) {
assert_eq!(data.len(), SECTOR_SIZE, "sector data must be exactly 2048 bytes");
assert_eq!(
data.len(),
SECTOR_SIZE,
"sector data must be exactly 2048 bytes"
);
self.sectors.insert(lba, data);
}
@@ -273,7 +279,10 @@ fn read_filesystem_no_partition_descriptor() {
reader.set_sector(32, make_terminator());
let result = udf::read_filesystem(&mut reader);
assert!(result.is_err(), "should fail when no partition descriptor in VDS");
assert!(
result.is_err(),
"should fail when no partition descriptor in VDS"
);
}
#[test]
@@ -425,7 +434,10 @@ fn find_dir_case_insensitive() {
// PLAYLIST (empty)
let playlist_data = make_parent_fid();
reader.set_sector(partition_start + 5, make_dir_icb(6, playlist_data.len() as u32));
reader.set_sector(
partition_start + 5,
make_dir_icb(6, playlist_data.len() as u32),
);
reader.set_sector_partial(partition_start + 6, &playlist_data);
let fs = udf::read_filesystem(&mut reader).expect("should parse");