From 4a6daabc795180586e981af519167ada364f7c7f Mon Sep 17 00:00:00 2001 From: skrrb Date: Tue, 12 Sep 2023 13:38:21 +0200 Subject: [PATCH] fuzz check f64 can be serialized --- .../openbook-v2/fuzz/fuzz_targets/multiple_orders.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs b/programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs index cdc4644cb..2bd1e3a5b 100644 --- a/programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs +++ b/programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs @@ -17,6 +17,13 @@ struct FuzzData { } impl FuzzData { + fn is_borsh_serializable(&self) -> bool { + self.instructions.iter().all(|ix| match ix { + FuzzInstruction::StubOracleSet { data, .. } => !data.price.is_nan(), + _ => true, + }) + } + fn contains_place_order_ixs(&self) -> bool { self.instructions.iter().any(|ix| { matches!( @@ -219,7 +226,7 @@ fuzz_target!(|fuzz_data: FuzzData| -> Corpus { }); fn run_fuzz(fuzz_data: FuzzData) -> Corpus { - if !fuzz_data.contains_place_order_ixs() { + if !fuzz_data.is_borsh_serializable() || !fuzz_data.contains_place_order_ixs() { return Corpus::Reject; }