[PATCH] D60571: [libFuzzer] Make MutateWithMask work when the Mask is shorter than the input.
Max Moroz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 11:24:07 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT358207: [libFuzzer] Make MutateWithMask work when the Mask is shorter than the input. (authored by Dor1s, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60571?vs=194720&id=194725#toc
Repository:
rCRT Compiler Runtime
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60571/new/
https://reviews.llvm.org/D60571
Files:
lib/fuzzer/FuzzerMutate.cpp
Index: lib/fuzzer/FuzzerMutate.cpp
===================================================================
--- lib/fuzzer/FuzzerMutate.cpp
+++ lib/fuzzer/FuzzerMutate.cpp
@@ -529,7 +529,7 @@
size_t MutationDispatcher::MutateWithMask(uint8_t *Data, size_t Size,
size_t MaxSize,
const Vector<uint8_t> &Mask) {
- assert(Size <= Mask.size());
+ size_t MaskedSize = std::min(Size, Mask.size());
// * Copy the worthy bytes into a temporary array T
// * Mutate T
// * Copy T back.
@@ -538,7 +538,7 @@
if (T.size() < Size)
T.resize(Size);
size_t OneBits = 0;
- for (size_t I = 0; I < Size; I++)
+ for (size_t I = 0; I < MaskedSize; I++)
if (Mask[I])
T[OneBits++] = Data[I];
@@ -548,7 +548,7 @@
assert(NewSize <= OneBits);
(void)NewSize;
// Even if NewSize < OneBits we still use all OneBits bytes.
- for (size_t I = 0, J = 0; I < Size; I++)
+ for (size_t I = 0, J = 0; I < MaskedSize; I++)
if (Mask[I])
Data[I] = T[J++];
return Size;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60571.194725.patch
Type: text/x-patch
Size: 1073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190411/1f0bc931/attachment.bin>
More information about the llvm-commits
mailing list