From e92d8c3e1769232562cdd6ca0de48a1d6b08247c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Cortier?= Date: Sat, 9 Mar 2024 00:44:12 +0900 Subject: [PATCH] test: regression test case for cliprdr_format target (#405) --- crates/ironrdp-cliprdr-format/src/bitmap.rs | 4 +-- ...h-0e7b5df5737a7ffc553c46c2425609f543b89498 | Bin 0 -> 41 bytes ...h-43677392fa06dda5f014e42dd06c9ae05cd19469 | Bin ...h-4485719597c99b83b2b761e497d03bf062b2461b | Bin ...h-65a50aad850d86155cae8c4c28f2937812cce53e | Bin ...h-93696ce8c9eec6824d9a3f99f960799d47b5d173 | Bin ...h-ce45f9ebf4ab1a51fcd0175952b22ab0fbcdc392 | Bin ...h-f8dc2df3f2aba63122b8912dff23e13210b408e9 | Bin .../tests/fuzz_regression.rs | 28 ++++++++++++++++++ crates/ironrdp-testsuite-core/tests/main.rs | 1 + .../ironrdp-testsuite-core/tests/pdu/mod.rs | 1 - .../tests/pdu/regression.rs | 11 ------- 12 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 crates/ironrdp-testsuite-core/test_data/fuzz_regression/cliprdr_format/crash-0e7b5df5737a7ffc553c46c2425609f543b89498 rename crates/ironrdp-testsuite-core/test_data/{pdu/regression => fuzz_regression/pdu_decode}/crash-43677392fa06dda5f014e42dd06c9ae05cd19469 (100%) rename crates/ironrdp-testsuite-core/test_data/{pdu/regression => fuzz_regression/pdu_decode}/crash-4485719597c99b83b2b761e497d03bf062b2461b (100%) rename crates/ironrdp-testsuite-core/test_data/{pdu/regression => fuzz_regression/pdu_decode}/crash-65a50aad850d86155cae8c4c28f2937812cce53e (100%) rename crates/ironrdp-testsuite-core/test_data/{pdu/regression => fuzz_regression/pdu_decode}/crash-93696ce8c9eec6824d9a3f99f960799d47b5d173 (100%) rename crates/ironrdp-testsuite-core/test_data/{pdu/regression => fuzz_regression/pdu_decode}/crash-ce45f9ebf4ab1a51fcd0175952b22ab0fbcdc392 (100%) rename crates/ironrdp-testsuite-core/test_data/{pdu/regression => fuzz_regression/pdu_decode}/crash-f8dc2df3f2aba63122b8912dff23e13210b408e9 (100%) create mode 100644 crates/ironrdp-testsuite-core/tests/fuzz_regression.rs delete mode 100644 crates/ironrdp-testsuite-core/tests/pdu/regression.rs diff --git a/crates/ironrdp-cliprdr-format/src/bitmap.rs b/crates/ironrdp-cliprdr-format/src/bitmap.rs index cea76cba8..c5d41faf4 100644 --- a/crates/ironrdp-cliprdr-format/src/bitmap.rs +++ b/crates/ironrdp-cliprdr-format/src/bitmap.rs @@ -199,9 +199,9 @@ impl BitmapInfoHeader { let size = src.read_u32(); - let width = src.read_i32(); - // NOTE: .abs() could panic on i32::MIN, therefore we have a check for it first. + + let width = src.read_i32(); check_invariant(width != i32::MIN && width.abs() <= 10_000) .ok_or_else(|| invalid_message_err!("biWidth", "width is too big"))?; diff --git a/crates/ironrdp-testsuite-core/test_data/fuzz_regression/cliprdr_format/crash-0e7b5df5737a7ffc553c46c2425609f543b89498 b/crates/ironrdp-testsuite-core/test_data/fuzz_regression/cliprdr_format/crash-0e7b5df5737a7ffc553c46c2425609f543b89498 new file mode 100644 index 0000000000000000000000000000000000000000..1b93940357210ec10d79c19a6f7a71865930e706 GIT binary patch literal 41 rcmZQ!V6b9fU}#`qU;$DLmjA#1`~UUp*P} {{ + use ironrdp_fuzzing::oracles; + + const REGRESSION_DATA_FOLDER: &str = concat!( + env!("CARGO_MANIFEST_DIR"), + concat!("/test_data/fuzz_regression/", stringify!($oracle)) + ); + + println!("Read directory {REGRESSION_DATA_FOLDER}"); + for entry in std::fs::read_dir(REGRESSION_DATA_FOLDER).unwrap() { + let entry = entry.unwrap(); + println!("Check {}", entry.path().display()); + let test_case = std::fs::read(entry.path()).unwrap(); + oracles::$oracle(&test_case); + } + }}; +} + +#[test] +pub fn check_pdu_decode() { + check!(pdu_decode); +} + +#[test] +pub fn check_cliprdr_format() { + check!(cliprdr_format); +} diff --git a/crates/ironrdp-testsuite-core/tests/main.rs b/crates/ironrdp-testsuite-core/tests/main.rs index fddaa030d..7efa52b73 100644 --- a/crates/ironrdp-testsuite-core/tests/main.rs +++ b/crates/ironrdp-testsuite-core/tests/main.rs @@ -11,6 +11,7 @@ mod clipboard; mod displaycontrol; +mod fuzz_regression; mod graphics; mod input; mod pcb; diff --git a/crates/ironrdp-testsuite-core/tests/pdu/mod.rs b/crates/ironrdp-testsuite-core/tests/pdu/mod.rs index 00c2a5f34..13110c527 100644 --- a/crates/ironrdp-testsuite-core/tests/pdu/mod.rs +++ b/crates/ironrdp-testsuite-core/tests/pdu/mod.rs @@ -4,6 +4,5 @@ mod input; mod mcs; mod pointer; mod rdp; -mod regression; mod rfx; mod x224; diff --git a/crates/ironrdp-testsuite-core/tests/pdu/regression.rs b/crates/ironrdp-testsuite-core/tests/pdu/regression.rs deleted file mode 100644 index ef7bc6323..000000000 --- a/crates/ironrdp-testsuite-core/tests/pdu/regression.rs +++ /dev/null @@ -1,11 +0,0 @@ -const REGRESSION_DATA_FOLDER: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/test_data/pdu/regression/"); - -#[test] -pub fn check() { - for entry in std::fs::read_dir(REGRESSION_DATA_FOLDER).unwrap() { - let entry = entry.unwrap(); - println!("Check {}", entry.path().display()); - let test_case = std::fs::read(entry.path()).unwrap(); - ironrdp_fuzzing::oracles::pdu_decode(&test_case); - } -}