mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-14 11:08:06 +00:00
fix scan-build issues
This commit is contained in:
@ -459,7 +459,7 @@ struct InsTrim : public ModulePass {
|
|||||||
BasicBlock *PBB = *PI;
|
BasicBlock *PBB = *PI;
|
||||||
auto It = PredMap.insert({PBB, genLabel()});
|
auto It = PredMap.insert({PBB, genLabel()});
|
||||||
unsigned Label = It.first->second;
|
unsigned Label = It.first->second;
|
||||||
cur_loc = Label;
|
// cur_loc = Label;
|
||||||
PN->addIncoming(ConstantInt::get(Int32Ty, Label), PBB);
|
PN->addIncoming(ConstantInt::get(Int32Ty, Label), PBB);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -760,7 +760,7 @@ bool ModuleSanitizerCoverage::instrumentModule(
|
|||||||
if (literalLength + 1 == optLength) {
|
if (literalLength + 1 == optLength) {
|
||||||
|
|
||||||
Str2.append("\0", 1); // add null byte
|
Str2.append("\0", 1); // add null byte
|
||||||
addedNull = true;
|
// addedNull = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ static std::string getSourceName(llvm::Function *F) {
|
|||||||
|
|
||||||
if (cDILoc) { instFilename = cDILoc->getFilename(); }
|
if (cDILoc) { instFilename = cDILoc->getFilename(); }
|
||||||
|
|
||||||
if (instFilename.str().empty()) {
|
if (instFilename.str().empty() && cDILoc) {
|
||||||
|
|
||||||
/* If the original location is empty, try using the inlined location
|
/* If the original location is empty, try using the inlined location
|
||||||
*/
|
*/
|
||||||
|
@ -430,7 +430,6 @@ bool AFLdict2filePass::runOnModule(Module &M) {
|
|||||||
if (literalLength + 1 == optLength) {
|
if (literalLength + 1 == optLength) {
|
||||||
|
|
||||||
Str2.append("\0", 1); // add null byte
|
Str2.append("\0", 1); // add null byte
|
||||||
addedNull = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
if (literalLength + 1 == optLength) {
|
if (literalLength + 1 == optLength) {
|
||||||
|
|
||||||
Str2.append("\0", 1); // add null byte
|
Str2.append("\0", 1); // add null byte
|
||||||
addedNull = true;
|
// addedNull = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,6 +538,7 @@ bool AFLCoverage::runOnModule(Module &M) {
|
|||||||
|
|
||||||
Store = IRB.CreateStore(ConstantInt::get(Int32Ty, cur_loc >> 1),
|
Store = IRB.CreateStore(ConstantInt::get(Int32Ty, cur_loc >> 1),
|
||||||
AFLPrevLoc);
|
AFLPrevLoc);
|
||||||
|
Store->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
|
|||||||
if (val && !val->empty()) {
|
if (val && !val->empty()) {
|
||||||
|
|
||||||
Str2 = StringRef(*val);
|
Str2 = StringRef(*val);
|
||||||
HasStr2 = true;
|
// HasStr2 = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,6 +407,7 @@ bool SplitComparesTransform::simplifyIntSignedness(Module &M) {
|
|||||||
auto op1 = IcmpInst->getOperand(1);
|
auto op1 = IcmpInst->getOperand(1);
|
||||||
|
|
||||||
IntegerType *intTyOp0 = dyn_cast<IntegerType>(op0->getType());
|
IntegerType *intTyOp0 = dyn_cast<IntegerType>(op0->getType());
|
||||||
|
if (!intTyOp0) { continue; }
|
||||||
unsigned bitw = intTyOp0->getBitWidth();
|
unsigned bitw = intTyOp0->getBitWidth();
|
||||||
IntegerType *IntType = IntegerType::get(C, bitw);
|
IntegerType *IntType = IntegerType::get(C, bitw);
|
||||||
|
|
||||||
@ -606,10 +607,11 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
|
|||||||
: sizeInBits == 64 ? 53
|
: sizeInBits == 64 ? 53
|
||||||
: sizeInBits == 128 ? 113
|
: sizeInBits == 128 ? 113
|
||||||
: sizeInBits == 16 ? 11
|
: sizeInBits == 16 ? 11
|
||||||
/* sizeInBits == 80 */
|
: sizeInBits == 80 ? 65
|
||||||
: 65;
|
: sizeInBits - 8;
|
||||||
|
|
||||||
const unsigned shiftR_exponent = precision - 1;
|
const unsigned shiftR_exponent = precision - 1;
|
||||||
|
// BUG FIXME TODO: u64 does not work for > 64 bit ... e.g. 80 and 128 bit
|
||||||
const unsigned long long mask_fraction =
|
const unsigned long long mask_fraction =
|
||||||
(1ULL << (shiftR_exponent - 1)) | ((1ULL << (shiftR_exponent - 1)) - 1);
|
(1ULL << (shiftR_exponent - 1)) | ((1ULL << (shiftR_exponent - 1)) - 1);
|
||||||
const unsigned long long mask_exponent =
|
const unsigned long long mask_exponent =
|
||||||
@ -1300,12 +1302,9 @@ bool SplitComparesTransform::runOnModule(Module &M) {
|
|||||||
|
|
||||||
case 64:
|
case 64:
|
||||||
count += splitIntCompares(M, bitw);
|
count += splitIntCompares(M, bitw);
|
||||||
/*
|
if (debug)
|
||||||
if (!be_quiet)
|
errs() << "Split-integer-compare-pass " << bitw << "bit: " << count
|
||||||
errs() << "Split-integer-compare-pass " << bitw << "bit: " <<
|
<< " split\n";
|
||||||
count
|
|
||||||
<< " split\n";
|
|
||||||
*/
|
|
||||||
bitw >>= 1;
|
bitw >>= 1;
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR > 3 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 7)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 7)
|
||||||
@ -1313,12 +1312,9 @@ bool SplitComparesTransform::runOnModule(Module &M) {
|
|||||||
#endif
|
#endif
|
||||||
case 32:
|
case 32:
|
||||||
count += splitIntCompares(M, bitw);
|
count += splitIntCompares(M, bitw);
|
||||||
/*
|
if (debug)
|
||||||
if (!be_quiet)
|
errs() << "Split-integer-compare-pass " << bitw << "bit: " << count
|
||||||
errs() << "Split-integer-compare-pass " << bitw << "bit: " <<
|
<< " split\n";
|
||||||
count
|
|
||||||
<< " split\n";
|
|
||||||
*/
|
|
||||||
bitw >>= 1;
|
bitw >>= 1;
|
||||||
#if LLVM_VERSION_MAJOR > 3 || \
|
#if LLVM_VERSION_MAJOR > 3 || \
|
||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 7)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 7)
|
||||||
@ -1326,13 +1322,10 @@ bool SplitComparesTransform::runOnModule(Module &M) {
|
|||||||
#endif
|
#endif
|
||||||
case 16:
|
case 16:
|
||||||
count += splitIntCompares(M, bitw);
|
count += splitIntCompares(M, bitw);
|
||||||
/*
|
if (debug)
|
||||||
if (!be_quiet)
|
errs() << "Split-integer-compare-pass " << bitw << "bit: " << count
|
||||||
errs() << "Split-integer-compare-pass " << bitw << "bit: " <<
|
<< " split\n";
|
||||||
count
|
// bitw >>= 1;
|
||||||
<< " split\n";
|
|
||||||
*/
|
|
||||||
bitw >>= 1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -315,16 +315,9 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
|||||||
u8 fortify_set = 0, asan_set = 0, x_set = 0, bit_mode = 0, shared_linking = 0,
|
u8 fortify_set = 0, asan_set = 0, x_set = 0, bit_mode = 0, shared_linking = 0,
|
||||||
preprocessor_only = 0, have_unroll = 0, have_o = 0, have_pic = 0,
|
preprocessor_only = 0, have_unroll = 0, have_o = 0, have_pic = 0,
|
||||||
have_c = 0;
|
have_c = 0;
|
||||||
u8 *name;
|
|
||||||
|
|
||||||
cc_params = ck_alloc((argc + 128) * sizeof(u8 *));
|
cc_params = ck_alloc((argc + 128) * sizeof(u8 *));
|
||||||
|
|
||||||
name = strrchr(argv[0], '/');
|
|
||||||
if (!name)
|
|
||||||
name = argv[0];
|
|
||||||
else
|
|
||||||
++name;
|
|
||||||
|
|
||||||
if (lto_mode) {
|
if (lto_mode) {
|
||||||
|
|
||||||
if (lto_flag[0] != '-')
|
if (lto_flag[0] != '-')
|
||||||
|
@ -1242,7 +1242,7 @@ static void link_or_copy(u8 *old_path, u8 *new_path) {
|
|||||||
|
|
||||||
void pivot_inputs(afl_state_t *afl) {
|
void pivot_inputs(afl_state_t *afl) {
|
||||||
|
|
||||||
struct queue_entry *q = afl->queue;
|
struct queue_entry *q;
|
||||||
u32 id = 0, i;
|
u32 id = 0, i;
|
||||||
|
|
||||||
ACTF("Creating hard links for all input files...");
|
ACTF("Creating hard links for all input files...");
|
||||||
|
@ -1415,7 +1415,7 @@ static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) {
|
|||||||
|
|
||||||
} else if (b[k] == 0xff) {
|
} else if (b[k] == 0xff) {
|
||||||
|
|
||||||
++cons_0;
|
++cons_ff;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -1473,7 +1473,7 @@ static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) {
|
|||||||
|
|
||||||
} else if (b[k] == 0xff) {
|
} else if (b[k] == 0xff) {
|
||||||
|
|
||||||
++cons_0;
|
++cons_ff;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -2410,7 +2410,21 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) {
|
|||||||
|
|
||||||
// manually clear the full cmp_map
|
// manually clear the full cmp_map
|
||||||
memset(afl->shm.cmp_map, 0, sizeof(struct cmp_map));
|
memset(afl->shm.cmp_map, 0, sizeof(struct cmp_map));
|
||||||
if (unlikely(common_fuzz_cmplog_stuff(afl, orig_buf, len))) { return 1; }
|
if (unlikely(common_fuzz_cmplog_stuff(afl, orig_buf, len))) {
|
||||||
|
|
||||||
|
afl->queue_cur->colorized = CMPLOG_LVL_MAX;
|
||||||
|
while (taint) {
|
||||||
|
|
||||||
|
t = taint->next;
|
||||||
|
ck_free(taint);
|
||||||
|
taint = t;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely(!afl->orig_cmp_map)) {
|
if (unlikely(!afl->orig_cmp_map)) {
|
||||||
|
|
||||||
afl->orig_cmp_map = ck_alloc_nozero(sizeof(struct cmp_map));
|
afl->orig_cmp_map = ck_alloc_nozero(sizeof(struct cmp_map));
|
||||||
@ -2419,7 +2433,20 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) {
|
|||||||
|
|
||||||
memcpy(afl->orig_cmp_map, afl->shm.cmp_map, sizeof(struct cmp_map));
|
memcpy(afl->orig_cmp_map, afl->shm.cmp_map, sizeof(struct cmp_map));
|
||||||
memset(afl->shm.cmp_map->headers, 0, sizeof(struct cmp_header) * CMP_MAP_W);
|
memset(afl->shm.cmp_map->headers, 0, sizeof(struct cmp_header) * CMP_MAP_W);
|
||||||
if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) { return 1; }
|
if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) {
|
||||||
|
|
||||||
|
afl->queue_cur->colorized = CMPLOG_LVL_MAX;
|
||||||
|
while (taint) {
|
||||||
|
|
||||||
|
t = taint->next;
|
||||||
|
ck_free(taint);
|
||||||
|
taint = t;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
dump("ORIG", orig_buf, len);
|
dump("ORIG", orig_buf, len);
|
||||||
@ -2530,7 +2557,6 @@ exit_its:
|
|||||||
afl->queue_cur->colorized = CMPLOG_LVL_MAX;
|
afl->queue_cur->colorized = CMPLOG_LVL_MAX;
|
||||||
|
|
||||||
ck_free(afl->queue_cur->cmplog_colorinput);
|
ck_free(afl->queue_cur->cmplog_colorinput);
|
||||||
t = taint;
|
|
||||||
while (taint) {
|
while (taint) {
|
||||||
|
|
||||||
t = taint->next;
|
t = taint->next;
|
||||||
|
Reference in New Issue
Block a user