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: added a call limit setting to prevent crashes or timeouts #684

Merged
merged 6 commits into from Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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 meta/fuzz/Cargo.toml
Expand Up @@ -8,6 +8,8 @@ rust-version = "1.56"
[package.metadata]
cargo-fuzz = true

[dependencies.pest]
path = "../../pest"
[dependencies.pest_meta]
path = ".."
[dependencies.libfuzzer-sys]
Expand Down
4 changes: 4 additions & 0 deletions meta/fuzz/fuzz_targets/parser.rs
Expand Up @@ -2,9 +2,13 @@
#[macro_use]
extern crate libfuzzer_sys;
extern crate pest_meta;
extern crate pest;

use std::convert::TryInto;

fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
pest::set_call_limit(Some(25_000usize.try_into().unwrap()));
let _ = pest_meta::parser::parse(pest_meta::parser::Rule::grammar_rules, s);
}
});
245 changes: 245 additions & 0 deletions meta/resources/test/fuzzsample1.grammar
@@ -0,0 +1,245 @@
w={
(((((((((((((((((((((((((((((((( (((((((((((((((((((((
((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( ((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( (((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( ((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( ((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( (((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( ((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( ((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((( (((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((
(((((
((((((((( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( ((((((( ((((((((((((((((((((((((
((((((((((((( (((((((((((((((((
((((((((((((((((((((((((((((((//( (((((((((((((((((((((((((w={
(( (((((((((((((((((((((((((((((
(((((
((((((((((((((((((((((( (((((((((((((((((((((((((((((
(((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( (((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((((((((((((((((((((((((
((( ((((((((((((((((((((((((
((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((//( ((((((((((((((((((((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((( ((((((((((((((((((((((( (((((((((((((((((( ((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((((( ((((((((((((((((((((((((((((((((((((((((((((((((( (((((((((((((((((((((((((((((
6 changes: 6 additions & 0 deletions meta/resources/test/fuzzsample2.grammar
@@ -0,0 +1,6 @@

/*//j/*/*;'//*//*/*/*;'/*//*/*;**//*//*/*/*;'/*/ /*//*/*/*;+/*//*/*;*B/*//*/*/*/*;'/*//*/*;**//*//*/*/*;'/*/ /*//*/*/*;+/*//*/*;*B/*//*//*/*;**N//*//*/*/*;'/*//*//*/

*//*/*;**N//*//*/*/*;'/*//*//*/

*/*;+/*//**/*/*;'/*//*//*;*/*///*/*;