[all-commits] [llvm/llvm-project] b07fee: [libc] This commit fixes the strcmp fuzzing test. ...

Chris Gyurgyik via All-commits all-commits at lists.llvm.org
Sun Jun 28 10:51:11 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b07feef8736d52e11c41631d3813a57a3b3ce6e5
      https://github.com/llvm/llvm-project/commit/b07feef8736d52e11c41631d3813a57a3b3ce6e5
  Author: cgyurgyik <gyurgyikcp at gmail.com>
  Date:   2020-06-28 (Sun, 28 Jun 2020)

  Changed paths:
    M libc/fuzzing/string/CMakeLists.txt
    M libc/fuzzing/string/strcmp_fuzz.cpp

  Log Message:
  -----------
  [libc] This commit fixes the strcmp fuzzing test. It uses a single input and
splits it into two by using the value of the first byte to determine the
length of the first string. Reviewed-by: PaulkaToast, Differential
Revision: https://reviews.llvm.org/D82427

Summary:
[libc] Since only one input is given, it is necessary to split the string into two containers so that they can be compared for the purposes of this fuzz test. This is done in the following manner:

1. Take the value of the first byte; this is size1. (Credits to @PaulkaToast for this idea).
2. size2 is the value of size - size1.
3. Copy the characters to new containers, data1 and data2 with corresponding sizes.
4. Add a null terminator to the first container, and verify the second container has a null terminator.
5. Verify output of strcmp.

A simpler alternative considered was simply splitting the input data into two, but this means the two strings are always within +- 1 character of each other. This above implementation avoids this.

ninja check-libc was run; no issues.

Reviewers: PaulkaToast, sivachandra

Reviewed By: PaulkaToast

Subscribers: mgorny, tschuett, ecnelises, libc-commits, PaulkaToast

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D82427




More information about the All-commits mailing list