Skip to content

Commit

Permalink
fix: put a call limit on the toml fuzzer (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtau committed Aug 14, 2022
1 parent 40e3752 commit 8d1f7b8
Show file tree
Hide file tree
Showing 5 changed files with 8,681 additions and 2 deletions.
2 changes: 2 additions & 0 deletions grammars/fuzz/Cargo.toml
Expand Up @@ -10,6 +10,8 @@ cargo-fuzz = true

[dependencies.pest_grammars]
path = ".."
[dependencies.pest]
path = "../../pest"
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"

Expand Down
3 changes: 2 additions & 1 deletion grammars/fuzz/fuzz_targets/json.rs
@@ -1,5 +1,6 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
#[macro_use]
extern crate libfuzzer_sys;
extern crate pest_grammars;

fuzz_target!(|data: &[u8]| {
Expand Down
7 changes: 6 additions & 1 deletion grammars/fuzz/fuzz_targets/toml.rs
@@ -1,12 +1,17 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
#[macro_use]
extern crate libfuzzer_sys;
extern crate pest;
extern crate pest_grammars;

use std::convert::TryInto;

fuzz_target!(|data: &[u8]| {
use pest_grammars::toml;
use pest_grammars::Parser;

if let Ok(s) = std::str::from_utf8(data) {
pest::set_call_limit(Some(100_000usize.try_into().unwrap()));
let _ = toml::TomlParser::parse(toml::Rule::toml, s);
}
});

0 comments on commit 8d1f7b8

Please sign in to comment.