rust-fuzz/targets

Add targets for 'http' crate

frewsxcv opened this issue · 4 comments

http just had it's 1.0 release

I threw together a fuzz target for StatusCode:

#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate http;

fuzz_target!(|data: &[u8]| {
    if let Ok(status_code) = http::status::StatusCode::from_bytes(data) {
        status_code.is_informational();
        status_code.is_success();
        status_code.is_redirection();
        status_code.is_client_error();
        status_code.is_server_error();
        status_code.to_string();
        let s = status_code.as_str();
        format!("{:?}", status_code);
        assert_eq!(
            status_code,
            http::status::StatusCode::from_bytes(s.as_bytes()).unwrap()
        );
    }
});

I think you meant 0.1 :)

The crate has a few of from_bytes methods. Do you want to add fuzzers for all of them?

yeah, seems appropriate to add fuzz targets for each of those, though i don't think there's too much nuanced logic in the 'http' crate that would catch any bugs, but you never know!