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 542395289c
commit eb83ebf1bd

View File

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