mirror of
https://gitee.com/openharmony/third_party_rust_proc-macro2
synced 2024-11-23 07:19:41 +00:00
Add fuzz target for fallback TokenStream parser
This commit is contained in:
parent
164a5fdee6
commit
4a8ad4d901
3
fuzz/.gitignore
vendored
Normal file
3
fuzz/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
artifacts/
|
||||
corpus/
|
||||
target/
|
21
fuzz/Cargo.toml
Normal file
21
fuzz/Cargo.toml
Normal file
@ -0,0 +1,21 @@
|
||||
[package]
|
||||
name = "proc-macro2-fuzz"
|
||||
version = "0.0.0"
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies]
|
||||
libfuzzer-sys = "0.4"
|
||||
proc-macro2 = { path = ".." }
|
||||
|
||||
[[bin]]
|
||||
name = "parse_token_stream"
|
||||
path = "fuzz_targets/parse_token_stream.rs"
|
||||
test = false
|
||||
doc = false
|
||||
|
||||
[workspace]
|
12
fuzz/fuzz_targets/parse_token_stream.rs
Normal file
12
fuzz/fuzz_targets/parse_token_stream.rs
Normal file
@ -0,0 +1,12 @@
|
||||
#![no_main]
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
use std::str;
|
||||
|
||||
fuzz_target!(|bytes: &[u8]| {
|
||||
if bytes.len() < 200 {
|
||||
if let Ok(string) = str::from_utf8(bytes) {
|
||||
_ = string.parse::<proc_macro2::TokenStream>();
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user