[llvm] r278986 - [libFuzzer] given 0 and 255 more preference when inserting repeated bytes

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 14:50:54 PDT 2016


Author: kcc
Date: Wed Aug 17 16:50:54 2016
New Revision: 278986

URL: http://llvm.org/viewvc/llvm-project?rev=278986&view=rev
Log:
[libFuzzer] given 0 and 255 more preference when inserting repeated bytes

Modified:
    llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp

Modified: llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp?rev=278986&r1=278985&r2=278986&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp Wed Aug 17 16:50:54 2016
@@ -129,7 +129,8 @@ size_t MutationDispatcher::Mutate_Insert
   size_t Idx = Rand(Size + 1);
   // Insert new values at Data[Idx].
   memmove(Data + Idx + N, Data + Idx, Size - Idx);
-  uint8_t Byte = RandCh(Rand);
+  // Give preference to 0x00 and 0xff.
+  uint8_t Byte = Rand.RandBool() ? Rand(256) : (Rand.RandBool() ? 0 : 255);
   for (size_t i = 0; i < N; i++)
     Data[Idx + i] = Byte;
   return Size + N;




More information about the llvm-commits mailing list