mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-12 10:08:07 +00:00
fix laf for potential crashes
This commit is contained in:
@ -362,19 +362,22 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
|
|||||||
bool HasStr1 = getConstantStringInfo(Str1P, Str1);
|
bool HasStr1 = getConstantStringInfo(Str1P, Str1);
|
||||||
bool HasStr2 = getConstantStringInfo(Str2P, Str2);
|
bool HasStr2 = getConstantStringInfo(Str2P, Str2);
|
||||||
uint64_t constStrLen, unrollLen, constSizedLen = 0;
|
uint64_t constStrLen, unrollLen, constSizedLen = 0;
|
||||||
bool isMemcmp =
|
bool isMemcmp = false;
|
||||||
!callInst->getCalledFunction()->getName().compare(StringRef("memcmp"));
|
bool isSizedcmp = false;
|
||||||
bool isSizedcmp = isMemcmp ||
|
bool isCaseInsensitive = false;
|
||||||
!callInst->getCalledFunction()->getName().compare(
|
Function * Callee = callInst->getCalledFunction();
|
||||||
StringRef("strncmp")) ||
|
if (Callee) {
|
||||||
!callInst->getCalledFunction()->getName().compare(
|
|
||||||
StringRef("strncasecmp"));
|
isMemcmp = Callee->getName().compare("memcmp") == 0;
|
||||||
|
isSizedcmp = isMemcmp || Callee->getName().compare("strncmp") == 0 ||
|
||||||
|
Callee->getName().compare("strncasecmp") == 0;
|
||||||
|
isCaseInsensitive = Callee->getName().compare("strcasecmp") == 0 ||
|
||||||
|
Callee->getName().compare("strncasecmp") == 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Value *sizedValue = isSizedcmp ? callInst->getArgOperand(2) : NULL;
|
Value *sizedValue = isSizedcmp ? callInst->getArgOperand(2) : NULL;
|
||||||
bool isConstSized = sizedValue && isa<ConstantInt>(sizedValue);
|
bool isConstSized = sizedValue && isa<ConstantInt>(sizedValue);
|
||||||
bool isCaseInsensitive = !callInst->getCalledFunction()->getName().compare(
|
|
||||||
StringRef("strcasecmp")) ||
|
|
||||||
!callInst->getCalledFunction()->getName().compare(
|
|
||||||
StringRef("strncasecmp"));
|
|
||||||
|
|
||||||
if (!(HasStr1 || HasStr2)) {
|
if (!(HasStr1 || HasStr2)) {
|
||||||
|
|
||||||
@ -436,15 +439,6 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
|
|||||||
else
|
else
|
||||||
unrollLen = constStrLen;
|
unrollLen = constStrLen;
|
||||||
|
|
||||||
/*
|
|
||||||
if (!be_quiet)
|
|
||||||
errs() << callInst->getCalledFunction()->getName() << ": unroll len "
|
|
||||||
<< unrollLen
|
|
||||||
<< ((isSizedcmp && !isConstSized) ? ", variable n" : "") << ":
|
|
||||||
"
|
|
||||||
<< ConstStr << "\n";
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* split before the call instruction */
|
/* split before the call instruction */
|
||||||
BasicBlock *bb = callInst->getParent();
|
BasicBlock *bb = callInst->getParent();
|
||||||
BasicBlock *end_bb = bb->splitBasicBlock(BasicBlock::iterator(callInst));
|
BasicBlock *end_bb = bb->splitBasicBlock(BasicBlock::iterator(callInst));
|
||||||
|
Reference in New Issue
Block a user