commit
0d042acb34
|
@ -0,0 +1,24 @@
|
|||
[package]
|
||||
name = "itoa-fuzz"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
edition = "2018"
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies]
|
||||
libfuzzer-sys = { version="0.4", features=["arbitrary-derive"] }
|
||||
|
||||
[dependencies.itoa]
|
||||
path = ".."
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
members = ["."]
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_itoa"
|
||||
path = "fuzz_targets/fuzz_itoa.rs"
|
||||
test = false
|
||||
doc = false
|
|
@ -0,0 +1,44 @@
|
|||
#![no_main]
|
||||
use libfuzzer_sys::arbitrary;
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
#[derive(arbitrary::Arbitrary, Debug, Clone)]
|
||||
enum IntegerInput {
|
||||
I8(i8),
|
||||
U8(u8),
|
||||
I16(i16),
|
||||
U16(u16),
|
||||
I32(i32),
|
||||
U32(u32),
|
||||
I64(i64),
|
||||
U64(u64),
|
||||
ISIZE(isize),
|
||||
USIZE(usize),
|
||||
I128(i128),
|
||||
U128(u128),
|
||||
}
|
||||
|
||||
#[derive(arbitrary::Arbitrary, Debug, Clone)]
|
||||
struct Inputs {
|
||||
inputs: Vec<IntegerInput>,
|
||||
}
|
||||
|
||||
fuzz_target!(|input: Inputs| {
|
||||
let mut buffer = itoa::Buffer::new();
|
||||
for input_integer in input.inputs {
|
||||
match input_integer {
|
||||
IntegerInput::I8(val) => buffer.format(val),
|
||||
IntegerInput::U8(val) => buffer.format(val),
|
||||
IntegerInput::I16(val) => buffer.format(val),
|
||||
IntegerInput::U16(val) => buffer.format(val),
|
||||
IntegerInput::I32(val) => buffer.format(val),
|
||||
IntegerInput::U32(val) => buffer.format(val),
|
||||
IntegerInput::I64(val) => buffer.format(val),
|
||||
IntegerInput::U64(val) => buffer.format(val),
|
||||
IntegerInput::ISIZE(val) => buffer.format(val),
|
||||
IntegerInput::USIZE(val) => buffer.format(val),
|
||||
IntegerInput::I128(val) => buffer.format(val),
|
||||
IntegerInput::U128(val) => buffer.format(val),
|
||||
};
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue