From 3e0bb788a7ef48edc05285f05ee7b628c7b23bdd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 22:33:39 -0500 Subject: [PATCH] test(video): bound Screen Video output and hostile packet handling --- ATTRIBUTION.md | 4 ++++ Cargo.lock | 1 + crates/video/src/screen_video.rs | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 9d260300c..7f9ba73c6 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -114,3 +114,7 @@ The XML reader in `crates/plist/src/xml.rs` and its base64 compatibility helper ## GIMP palette reader `crates/palette` extracts the GPL text parser from AniCraft `crates/doc/src/swatch.rs` at `d875a7feb250e6ab06aa28a37fb78a0699e88330` (MIT OR Apache-2.0), introduced by Tanish Manku in `a64130a9da9bdde545463b852d95d6a6774b1dfd` (AniCraft #270). The import preserves Tanish as primary author. Neutral RGB/name adaptation separates application display-name sanitization and the `Untitled` policy; validation tests and integration are subsequent Dylan M. Taylor changes. + +## Screen Video key frames + +`crates/video/src/screen_video.rs` extracts AniCraft `crates/xfl/src/video.rs` codec-3 decoding and its synthetic partial-block fixture, introduced by Tanish Manku in `1f3e603b7ff53a3da364e41ec4da8d43dc83aab0` with pixel-loop cleanup `2b7571363b4b647266df758f95b6e397021cfd4d` (MIT OR Apache-2.0). Import commits preserve Tanish as primary author. Caller-owned bounds and neutral RGBA output separate codec work from the consuming app's FLV first-frame/report policy. Boundary tests and integration are subsequent Dylan M. Taylor changes. diff --git a/Cargo.lock b/Cargo.lock index 1ac11475f..0ebe83376 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3286,6 +3286,7 @@ dependencies = [ "craft-jpeg", "craft-media", "craft-media-testkit", + "miniz_oxide 0.8.9", "rav1e", "rayon", "thiserror 2.0.21", diff --git a/crates/video/src/screen_video.rs b/crates/video/src/screen_video.rs index bb2ced9da..aab4718fb 100644 --- a/crates/video/src/screen_video.rs +++ b/crates/video/src/screen_video.rs @@ -99,4 +99,21 @@ mod tests { assert_eq!(&rgba[i..i + 4], &[r, g, b, 255], "({x}, {y})"); } } + #[test] + fn limits_truncation_and_unchanged_blocks_are_refused() { + let p = packet(40, 20, 16, |x, y| [x as u8, y as u8, 7]); + assert!(decode_keyframe(&p, 40, 40 * 20 * 4).is_some()); + assert!(decode_keyframe(&p, 39, usize::MAX).is_none()); + assert!(decode_keyframe(&p, 40, 40 * 20 * 4 - 1).is_none()); + for cut in 0..p.len() { + let _ = decode_keyframe(&p[..cut], 40, 40 * 20 * 4); + } + let mut unchanged = p.clone(); + unchanged[4..6].fill(0); + assert!(decode_keyframe(&unchanged, 40, 40 * 20 * 4).is_none()); + assert!(decode_keyframe(&[0, 0, 0, 0], 40, usize::MAX).is_none()); + let mut trailing = p.clone(); + trailing.extend_from_slice(&[1, 2, 3]); + assert_eq!(decode_keyframe(&trailing, 40, 3200), decode_keyframe(&p, 40, 3200)); + } }