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: decrease a call limit on the toml fuzzer #698

Merged
merged 1 commit into from Aug 19, 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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -93,7 +93,12 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --all --verbose
args: --all --verbose --release
- name: Cargo test (run ignored)
uses: actions-rs/cargo@v1
with:
command: test
args: -p pest_grammars --lib --verbose --release -- --ignored tests::toml_handles_deep_nesting_unstable

coverage:
name: Test Coverage
Expand Down
2 changes: 1 addition & 1 deletion grammars/fuzz/fuzz_targets/toml.rs
Expand Up @@ -11,7 +11,7 @@ fuzz_target!(|data: &[u8]| {
use pest_grammars::Parser;

if let Ok(s) = std::str::from_utf8(data) {
pest::set_call_limit(Some(100_000usize.try_into().unwrap()));
pest::set_call_limit(Some(5_000usize.try_into().unwrap()));
let _ = toml::TomlParser::parse(toml::Rule::toml, s);
}
});
5 changes: 5 additions & 0 deletions grammars/resources/test/tomlfuzzsample2.toml
@@ -0,0 +1,5 @@
[1]O=[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{x=1,O=[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{x=1,O=8,x=6,O=5,z=8,Ox4=[[[[[[[[[[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[[[[[[[[[[[[[[[[[[[[[{x=1,O=8,x=5,O=5,z=8,Ox3=[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[1,5,

[1,5
,5
,170141183460469231731687303715916988704O=8
24 changes: 19 additions & 5 deletions grammars/src/lib.rs
Expand Up @@ -41,17 +41,31 @@ mod tests {

use crate::{json, toml};

fn test_toml_deep_nesting(input: &str) {
const ERROR: &str = "call limit reached";
pest::set_call_limit(Some(5_000usize.try_into().unwrap()));
let s = toml::TomlParser::parse(toml::Rule::toml, input);
assert!(s.is_err());
assert_eq!(s.unwrap_err().variant.message(), ERROR);
}

#[test]
fn toml_handles_deep_nesting() {
let sample1 = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/resources/test/tomlfuzzsample1.toml"
));
const ERROR: &str = "call limit reached";
pest::set_call_limit(Some(100_000usize.try_into().unwrap()));
let s1 = toml::TomlParser::parse(toml::Rule::toml, sample1);
assert!(s1.is_err());
assert_eq!(s1.unwrap_err().variant.message(), ERROR);
test_toml_deep_nesting(sample1);
}

#[test]
#[ignore = "this sometimes crashes in the debug mode"]
fn toml_handles_deep_nesting_unstable() {
let sample2 = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/resources/test/tomlfuzzsample2.toml"
));
test_toml_deep_nesting(sample2);
}

#[test]
Expand Down