Skip to content

Reject unwanted inputs in "Writing harnesses" example #22

Open
@mschwager

Description

@mschwager

We could improve the C/C++ example provided here.

We could turn the following code:

    // Ensure exactly 2 4-byte numbers (numerator and denominator) are read
    if(size != 2 * sizeof(uint32_t)){
        return 0;
    }

To something like:

    // Ensure exactly 2 4-byte numbers (numerator and denominator) are read
    if(size != 2 * sizeof(uint32_t)){
        return -1;  // Reject; The input will not be added to the corpus.
    }

As documented here. This makes the fuzzing harness more efficient, and documents the "reject input" feature of libFuzzer. We should then explain the return -1; and drop a link to the libFuzzer docs in the following paragraph.

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