mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-12 13:48:45 +00:00
[libFuzzer] extend the dictionary mutator to optionally overwrite data with the dict entry
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256900 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f776cd591c
commit
92ec084eaf
@ -117,11 +117,18 @@ size_t MutationDispatcher::Mutate_AddWordFromDictionary(uint8_t *Data,
|
||||
assert(!D.empty());
|
||||
if (D.empty()) return 0;
|
||||
const Unit &Word = D[Rand(D.size())];
|
||||
if (Size + Word.size() > MaxSize) return 0;
|
||||
size_t Idx = Rand(Size + 1);
|
||||
memmove(Data + Idx + Word.size(), Data + Idx, Size - Idx);
|
||||
memcpy(Data + Idx, Word.data(), Word.size());
|
||||
return Size + Word.size();
|
||||
if (Rand.RandBool()) { // Insert Word.
|
||||
if (Size + Word.size() > MaxSize) return 0;
|
||||
size_t Idx = Rand(Size + 1);
|
||||
memmove(Data + Idx + Word.size(), Data + Idx, Size - Idx);
|
||||
memcpy(Data + Idx, Word.data(), Word.size());
|
||||
return Size + Word.size();
|
||||
} else { // Overwrite some bytes with Word.
|
||||
if (Word.size() > Size) return 0;
|
||||
size_t Idx = Rand(Size - Word.size());
|
||||
memcpy(Data + Idx, Word.data(), Word.size());
|
||||
return Size;
|
||||
}
|
||||
}
|
||||
|
||||
size_t MutationDispatcher::Mutate_ChangeASCIIInteger(uint8_t *Data, size_t Size,
|
||||
|
Loading…
x
Reference in New Issue
Block a user