feat: add fuzz crate scaffold and fuzz_parse_command target
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c59bb719d5
commit
60bef00b00
3 changed files with 61 additions and 0 deletions
4
lib/fuzz/.gitignore
vendored
Normal file
4
lib/fuzz/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
target/
|
||||
corpus/
|
||||
artifacts/
|
||||
Cargo.lock
|
||||
44
lib/fuzz/Cargo.toml
Normal file
44
lib/fuzz/Cargo.toml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
[package]
|
||||
name = "usbip-rs-fuzz"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
edition = "2024"
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies]
|
||||
libfuzzer-sys = "0.4"
|
||||
tokio = { version = "1", features = ["rt-multi-thread", "sync", "time", "io-util"] }
|
||||
|
||||
[dependencies.usbip-rs]
|
||||
path = ".."
|
||||
features = ["fuzz"]
|
||||
|
||||
[workspace]
|
||||
members = ["."]
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_parse_command"
|
||||
path = "fuzz_targets/fuzz_parse_command.rs"
|
||||
doc = false
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_handle_client"
|
||||
path = "fuzz_targets/fuzz_handle_client.rs"
|
||||
doc = false
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_urb_hid"
|
||||
path = "fuzz_targets/fuzz_urb_hid.rs"
|
||||
doc = false
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_urb_uac"
|
||||
path = "fuzz_targets/fuzz_urb_uac.rs"
|
||||
doc = false
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_urb_cdc"
|
||||
path = "fuzz_targets/fuzz_urb_cdc.rs"
|
||||
doc = false
|
||||
13
lib/fuzz/fuzz_targets/fuzz_parse_command.rs
Normal file
13
lib/fuzz/fuzz_targets/fuzz_parse_command.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#![no_main]
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
use usbip_rs::mock::MockSocket;
|
||||
use usbip_rs::usbip_protocol::UsbIpCommand;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.build()
|
||||
.unwrap();
|
||||
let mut socket = MockSocket::new(data.to_vec());
|
||||
let _ = rt.block_on(UsbIpCommand::read_from_socket(&mut socket));
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue