From eb83ebf1bd98f77e877539b05d07ffcfddb87f6f Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Wed, 5 May 2021 22:08:25 +0200 Subject: [PATCH] Do not apply mutation if it is too large. --- .../tools/ossfuzz/SolidityCustomMutatorInterface.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/tools/ossfuzz/SolidityCustomMutatorInterface.cpp b/test/tools/ossfuzz/SolidityCustomMutatorInterface.cpp index fad3f08a4..11814574a 100644 --- a/test/tools/ossfuzz/SolidityCustomMutatorInterface.cpp +++ b/test/tools/ossfuzz/SolidityCustomMutatorInterface.cpp @@ -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(); + } }