Do not apply mutation if it is too large.

This commit is contained in:
Bhargava Shastry 2021-05-05 22:08:25 +02:00
parent a0197138d9
commit 1d6d8e68f8

View File

@ -64,7 +64,13 @@ size_t SolidityCustomMutatorInterface::generate()
data,
"Solc custom mutator: Invalid mutant or memory pointer"
);
size_t mutantSize = min(testCase.size(), maxMutantSize - 1);
mempcpy(data, testCase.data(), mutantSize);
return mutantSize;
// Do not apply the mutation if mutant is greater in size than maximum
// permissible. libFuzzer's default max permissible is around 4 KB.
if (testCase.size() > (maxMutantSize - 1))
return size;
else
{
mempcpy(data, testCase.data(), testCase.size());
return testCase.size();
}
}