mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1400513 - u2f-hid-rs: fuzzers should use a deterministic cmd byte r=jcj
Summary: We're currently using the thread_rng to derive a cmd byte for the U2F protocol fuzzers. That of course should rather be derived deterministically from the input handed to the fuzzing target. Bug #: 1400513 Differential Revision: https://phabricator.services.mozilla.com/D61
This commit is contained in:
parent
efb7d369f2
commit
cd9cddcc94
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -4,10 +4,8 @@
|
||||
|
||||
#![no_main]
|
||||
#[macro_use] extern crate libfuzzer_sys;
|
||||
extern crate rand;
|
||||
extern crate u2fhid;
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::{cmp, io};
|
||||
|
||||
use u2fhid::{CID_BROADCAST, HID_RPT_SIZE};
|
||||
@ -59,7 +57,10 @@ impl<'a> U2FDevice for TestDevice<'a> {
|
||||
}
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let mut dev = TestDevice::new(data);
|
||||
let cmd = thread_rng().gen::<u8>();
|
||||
let _ = sendrecv(&mut dev, cmd, data);
|
||||
if data.len() > 0 {
|
||||
let cmd = data[0];
|
||||
let data = &data[1..];
|
||||
let mut dev = TestDevice::new(data);
|
||||
let _ = sendrecv(&mut dev, cmd, data);
|
||||
}
|
||||
});
|
||||
|
@ -4,10 +4,8 @@
|
||||
|
||||
#![no_main]
|
||||
#[macro_use] extern crate libfuzzer_sys;
|
||||
extern crate rand;
|
||||
extern crate u2fhid;
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::{cmp, io};
|
||||
|
||||
use u2fhid::{CID_BROADCAST, HID_RPT_SIZE};
|
||||
@ -60,8 +58,11 @@ impl U2FDevice for TestDevice {
|
||||
}
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let mut dev = TestDevice::new();
|
||||
let cmd = thread_rng().gen::<u8>();
|
||||
let res = sendrecv(&mut dev, cmd, data);
|
||||
assert_eq!(data, &res.unwrap()[..]);
|
||||
if data.len() > 0 {
|
||||
let cmd = data[0];
|
||||
let data = &data[1..];
|
||||
let mut dev = TestDevice::new();
|
||||
let res = sendrecv(&mut dev, cmd, data);
|
||||
assert_eq!(data, &res.unwrap()[..]);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user