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

Simplify fuzzing targets #157

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Simplify fuzzing targets
By passing &str, rather than [u8], the output is also nicer (i.e.
```bash
`std::fmt::Debug`:

        "\u{0}\u{0}\"\"\u{5}{ca*a,r#")
```
  • Loading branch information
MidasLamb committed Feb 4, 2022
commit f147032f35eb6526141cd03f0a6a4e82805d2914
9 changes: 2 additions & 7 deletions fuzz/fuzz_targets/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
use apollo_parser::Parser;
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let s = match std::str::from_utf8(data) {
Err(_) => return,
Ok(s) => s,
};

let _parser = Parser::new(s);
fuzz_target!(|data: &str| {
let _parser = Parser::new(data);
});
9 changes: 2 additions & 7 deletions fuzz/fuzz_targets/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ use apollo_parser::Parser;
use libfuzzer_sys::fuzz_target;
use std::panic;

fuzz_target!(|data: &[u8]| {
let s = match std::str::from_utf8(data) {
Err(_) => return,
Ok(s) => s,
};

let parser = panic::catch_unwind(|| Parser::new(s));
fuzz_target!(|data: &str| {
let parser = panic::catch_unwind(|| Parser::new(data));

let parser = match parser {
Err(_) => return,
Expand Down