Fuzzing for Vec<u8>

This commit is contained in:
Kirk Baird 2019-02-21 14:23:21 +11:00
parent 274bdd491d
commit 68017b66fd
No known key found for this signature in database
GPG Key ID: BF864B7ED0BEA33F
3 changed files with 44 additions and 0 deletions

View File

@ -83,3 +83,11 @@ path = "fuzz_targets/fuzz_target_address_decode.rs"
[[bin]]
name = "fuzz_target_address_encode"
path = "fuzz_targets/fuzz_target_address_encode.rs"
[[bin]]
name = "fuzz_target_vec_decode"
path = "fuzz_targets/fuzz_target_vec_decode.rs"
[[bin]]
name = "fuzz_target_vec_encode"
path = "fuzz_targets/fuzz_target_vec_encode.rs"

View File

@ -0,0 +1,21 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate ethereum_types;
extern crate ssz;
use ethereum_types::{Address, H256};
use ssz::{DecodeError, Decodable};
// Fuzz ssz_decode()
fuzz_target!(|data: &[u8]| {
let _result: Result<(Vec<u8>, usize), DecodeError> = Decodable::ssz_decode(data, 0);
/*
let _result: Result<(Vec<u16>, usize), DecodeError> = Decodable::ssz_decode(data, 0);
let _result: Result<(Vec<u32>, usize), DecodeError> = Decodable::ssz_decode(data, 0);
let _result: Result<(Vec<u64>, usize), DecodeError> = Decodable::ssz_decode(data, 0);
let _result: Result<(Vec<usize>, usize), DecodeError> = Decodable::ssz_decode(data, 0);
let _result: Result<(Vec<Address>, usize), DecodeError> = Decodable::ssz_decode(data, 0);
let _result: Result<(Vec<H256>, usize), DecodeError> = Decodable::ssz_decode(data, 0);
let _result: Result<(Vec<bool>, usize), DecodeError> = Decodable::ssz_decode(data, 0);
*/
});

View File

@ -0,0 +1,15 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate ethereum_types;
extern crate ssz;
use ethereum_types::{Address, H256};
use ssz::SszStream;
// Fuzz ssz_decode()
fuzz_target!(|data: &[u8]| {
let mut ssz = SszStream::new();
let data_vec = data.to_vec();
ssz.append(&data_vec);
});