diff options
author | Geoffroy Couprie <geo.couprie@gmail.com> | 2021-03-25 13:40:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-25 05:40:30 -0700 |
commit | 0282c8c4955e1811882caecf4861f1a5a32bd293 (patch) | |
tree | 8e55ae7802035a6938aa36b74f76ab4b79d108d6 /projects/nom | |
parent | fccea98eb75bfbf11d701300261bd1feda8ea66f (diff) |
use the fuzz directory from nom's repository (#5499)
Diffstat (limited to 'projects/nom')
-rw-r--r-- | projects/nom/fuzz/Cargo.toml | 24 | ||||
-rw-r--r-- | projects/nom/fuzz/fuzz_targets/fuzz_arithmetic.rs | 71 |
2 files changed, 0 insertions, 95 deletions
diff --git a/projects/nom/fuzz/Cargo.toml b/projects/nom/fuzz/Cargo.toml deleted file mode 100644 index ebb6be68..00000000 --- a/projects/nom/fuzz/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ - -[package] -name = "nom-fuzz" -version = "0.0.0" -authors = ["David Korczynski <david@adalogics.com>"] -publish = false -edition = "2018" - -[package.metadata] -cargo-fuzz = true - -[dependencies] -libfuzzer-sys = "0.3" - -[dependencies.nom] -path = ".." - -# Prevent this from interfering with workspaces -[workspace] -members = ["."] - -[[bin]] -name = "fuzz_arithmetic" -path = "fuzz_targets/fuzz_arithmetic.rs" diff --git a/projects/nom/fuzz/fuzz_targets/fuzz_arithmetic.rs b/projects/nom/fuzz/fuzz_targets/fuzz_arithmetic.rs deleted file mode 100644 index d548dcc9..00000000 --- a/projects/nom/fuzz/fuzz_targets/fuzz_arithmetic.rs +++ /dev/null @@ -1,71 +0,0 @@ -#![no_main] -use libfuzzer_sys::fuzz_target; -use std::str; - -extern crate nom; - -use nom::{ - branch::alt, - bytes::complete::tag, - character::complete::char, - character::complete::{digit1 as digit, space0 as space}, - combinator::map_res, - multi::fold_many0, - sequence::{delimited, pair}, - IResult, -}; - -use std::str::FromStr; - -fn parens(i: &str) -> IResult<&str, i64> { - delimited(space, delimited(tag("("), expr, tag(")")), space)(i) -} - - -fn factor(i: &str) -> IResult<&str, i64> { - alt(( - map_res(delimited(space, digit, space), FromStr::from_str), - parens, - ))(i) -} - - -fn term(i: &str) -> IResult<&str, i64> { - let (i, init) = factor(i)?; - - fold_many0( - pair(alt((char('*'), char('/'))), factor), - init, - |acc, (op, val): (char, i64)| { - if op == '*' { - acc * val - } else { - acc / val - } - }, - )(i) -} - -fn expr(i: &str) -> IResult<&str, i64> { - let (i, init) = term(i)?; - - fold_many0( - pair(alt((char('+'), char('-'))), term), - init, - |acc, (op, val): (char, i64)| { - if op == '+' { - acc + val - } else { - acc - val - } - }, - )(i) -} - -fuzz_target!(|data: &[u8]| { - // fuzzed code goes here - let temp = match str::from_utf8(data) { - Ok(v) => factor(v), - Err(e) => factor("2"), - }; -}); |