diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index d7bbc84c3..b11f6e5b2 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -42,3 +42,9 @@ name = "zkas-decoder" path = "fuzz_targets/zkas_decoder.rs" test = false doc = false + +[[bin]] +name = "decode-string" +path = "fuzz_targets/decode_string.rs" +test = false +doc = false diff --git a/fuzz/corpus/decode-string/corpora_oom_string_decode b/fuzz/corpus/decode-string/corpora_oom_string_decode new file mode 100644 index 000000000..650fd3c12 Binary files /dev/null and b/fuzz/corpus/decode-string/corpora_oom_string_decode differ diff --git a/fuzz/fuzz_targets/decode_string.rs b/fuzz/fuzz_targets/decode_string.rs new file mode 100644 index 000000000..4d58621bf --- /dev/null +++ b/fuzz/fuzz_targets/decode_string.rs @@ -0,0 +1,31 @@ +/* This file is part of DarkFi (https://dark.fi) + * + * Copyright (C) 2020-2023 Dyne.org foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#![no_main] +extern crate darkfi_serial; +use darkfi_serial::deserialize; + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + // Deserialize arbitrary data as a String + let _res: String = match deserialize::(&data) { + Ok(..) => "".to_string(), + Err(..) => "".to_string(), + }; +});