Skip to content

Mention &str being valid input in tutorial #54

@tertsdiepraam

Description

@tertsdiepraam

Hi!

The tutorial section of the book uses this example:

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

fuzz_target!(|data: &[u8]| {
    if let Ok(s) = std::str::from_utf8(data) {
        let _ = url::Url::parse(s);
    }
});

This example works, but is of course not as idiomatic as this:

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

fuzz_target!(|data: &str| {
    let _ = url::Url::parse(data);
});

I understand why you'd want to use the &[u8] to explain how the fuzzer works, but I think the second example should at least be mentioned in addition to the first. If you don't want to add it to the tutorial section, then maybe consider adding it to the Structure-Aware Fuzzing section, because I don't think &str is mentioned there either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions