-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from martinling/fuzzer
Fuzzer
- Loading branch information
Showing
7 changed files
with
107 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Fuzz the USB packet decoder. | ||
|
||
#![allow(dead_code)] | ||
#![no_main] | ||
|
||
#[macro_use] | ||
extern crate bitfield; | ||
|
||
use libfuzzer_sys::{arbitrary::{Arbitrary, Unstructured}, fuzz_target}; | ||
|
||
mod capture; | ||
mod compact_index; | ||
mod data_stream; | ||
mod decoder; | ||
mod id; | ||
mod index_stream; | ||
mod pcap; | ||
mod rcu; | ||
mod stream; | ||
mod usb; | ||
mod util; | ||
mod vec_map; | ||
|
||
use capture::create_capture; | ||
use decoder::Decoder; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
let mut input = Unstructured::new(data); | ||
let packets = Vec::<(Vec::<u8>, u32)>::arbitrary(&mut input).unwrap(); | ||
let mut timestamp = u32::arbitrary(&mut input).unwrap() as u64; | ||
let (writer, _reader) = create_capture().unwrap(); | ||
let mut decoder = Decoder::new(writer).unwrap(); | ||
for (packet, time_delta) in packets { | ||
timestamp += time_delta as u64; | ||
decoder.handle_raw_packet(&packet, timestamp).unwrap(); | ||
} | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Polling 1 times for unidentified transfer on endpoint 7.1 IN | ||
IN transaction on 7.1, NAK | ||
IN packet on 7.1, CRC 1B | ||
NAK packet | ||
1 invalid groups | ||
1 malformed packet | ||
Malformed packet (possibly IN, but bad CRC) of 3 bytes: [69, B7, DB] | ||
1 invalid groups | ||
1 malformed packet | ||
Malformed packet (possibly IN, but bad CRC) of 3 bytes: [69, B7, DB] | ||
1 invalid groups | ||
1 malformed packet | ||
Malformed packet (possibly SOF, but bad CRC) of 3 bytes: [A5, BB, CE] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
analyzer-test-bad-cable | ||
bad-crcs | ||
emf2022-badge | ||
hackrf-connect | ||
hackrf-dfu-enum | ||
|