From 0282c8c4955e1811882caecf4861f1a5a32bd293 Mon Sep 17 00:00:00 2001 From: Geoffroy Couprie Date: Thu, 25 Mar 2021 13:40:30 +0100 Subject: [PATCH] use the fuzz directory from nom's repository (#5499) added in https://github.com/Geal/nom/commit/0a499cd123cca25bd48d243c0109147c7627f155 --- projects/nom/fuzz/Cargo.toml | 24 ------- .../nom/fuzz/fuzz_targets/fuzz_arithmetic.rs | 71 ------------------- 2 files changed, 95 deletions(-) delete mode 100644 projects/nom/fuzz/Cargo.toml delete mode 100644 projects/nom/fuzz/fuzz_targets/fuzz_arithmetic.rs diff --git a/projects/nom/fuzz/Cargo.toml b/projects/nom/fuzz/Cargo.toml deleted file mode 100644 index ebb6be68b..000000000 --- a/projects/nom/fuzz/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ - -[package] -name = "nom-fuzz" -version = "0.0.0" -authors = ["David Korczynski "] -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 d548dcc94..000000000 --- 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"), - }; -});