[PATCH] D45693: [LibFuzzer] Tweak `MutationDispatcher::Mutate_CopyPart` mutation.

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 16 09:39:47 PDT 2018


delcypher created this revision.
delcypher added reviewers: kcc, george.karpenkov.
Herald added a subscriber: Sanitizers.

[LibFuzzer] Tweak `MutationDispatcher::Mutate_CopyPart` mutation.

It doesn't make sense to non-deterministically choose between
`CopyPart(..)` and `InsertPart(..)` when it is known that
`InsertPart(..)` will fail.

This upstream's a change from JFS solver's fork of LibFuzzer.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D45693

Files:
  lib/fuzzer/FuzzerMutate.cpp


Index: lib/fuzzer/FuzzerMutate.cpp
===================================================================
--- lib/fuzzer/FuzzerMutate.cpp
+++ lib/fuzzer/FuzzerMutate.cpp
@@ -339,7 +339,9 @@
 size_t MutationDispatcher::Mutate_CopyPart(uint8_t *Data, size_t Size,
                                            size_t MaxSize) {
   if (Size > MaxSize || Size == 0) return 0;
-  if (Rand.RandBool())
+  // If Size == MaxSize, `InsertPartOf(...)` will
+  // fail so there's no point using it in this case.
+  if (Size == MaxSize || Rand.RandBool())
     return CopyPartOf(Data, Size, Data, Size);
   else
     return InsertPartOf(Data, Size, Data, Size, MaxSize);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45693.142650.patch
Type: text/x-patch
Size: 654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180416/c5d346f8/attachment.bin>


More information about the llvm-commits mailing list