trailofbits / trailofbits/testing-handbook

Reject unwanted inputs in "Writing harnesses" example

Open
#22 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
135
Forks
22
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the “Beyond byte arrays” section of the Writing harnesses example and compare its size check with the linked libFuzzer documentation on rejecting unwanted inputs. Update the example and following paragraph so the rejection return value is explained and the libFuzzer link is included.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.