Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject unwanted inputs in "Writing harnesses" example #22

Open
mschwager opened this issue Feb 23, 2024 · 1 comment
Open

Reject unwanted inputs in "Writing harnesses" example #22

mschwager opened this issue Feb 23, 2024 · 1 comment

Comments

@mschwager
Copy link
Member

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.

@maxammann
Copy link
Contributor

sounds good, however we should note that AFL++ ignore the return value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants