Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: put a call limit on the toml fuzzer #692

Merged
merged 1 commit into from Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}
});