mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-16 03:48:08 +00:00
code-format
This commit is contained in:
@ -1027,11 +1027,15 @@ static inline u32 rand_below(afl_state_t *afl, u32 limit) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modulo is biased - we don't want our fuzzing to be biased so let's do it right. */
|
/* Modulo is biased - we don't want our fuzzing to be biased so let's do it
|
||||||
|
* right. */
|
||||||
u64 unbiased_rnd;
|
u64 unbiased_rnd;
|
||||||
do {
|
do {
|
||||||
|
|
||||||
unbiased_rnd = rand_next(afl);
|
unbiased_rnd = rand_next(afl);
|
||||||
|
|
||||||
} while (unlikely(unbiased_rnd >= (UINT64_MAX - (UINT64_MAX % limit))));
|
} while (unlikely(unbiased_rnd >= (UINT64_MAX - (UINT64_MAX % limit))));
|
||||||
|
|
||||||
return unbiased_rnd % limit;
|
return unbiased_rnd % limit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -812,16 +812,24 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
ptr += strlen("ngram");
|
ptr += strlen("ngram");
|
||||||
while (*ptr && (*ptr < '0' || *ptr > '9')) {
|
while (*ptr && (*ptr < '0' || *ptr > '9')) {
|
||||||
|
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*ptr) {
|
if (!*ptr) {
|
||||||
|
|
||||||
ptr = getenv("AFL_LLVM_NGRAM_SIZE");
|
ptr = getenv("AFL_LLVM_NGRAM_SIZE");
|
||||||
if (!ptr || !*ptr) {
|
if (!ptr || !*ptr) {
|
||||||
|
|
||||||
FATAL(
|
FATAL(
|
||||||
"you must set the NGRAM size with (e.g. for value 2) "
|
"you must set the NGRAM size with (e.g. for value 2) "
|
||||||
"AFL_LLVM_INSTRUMENT=ngram-2");
|
"AFL_LLVM_INSTRUMENT=ngram-2");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngram_size = atoi(ptr);
|
ngram_size = atoi(ptr);
|
||||||
if (ngram_size < 2 || ngram_size > NGRAM_SIZE_MAX)
|
if (ngram_size < 2 || ngram_size > NGRAM_SIZE_MAX)
|
||||||
FATAL(
|
FATAL(
|
||||||
|
@ -344,14 +344,10 @@ static std::string getSourceName(llvm::Function *F) {
|
|||||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7)
|
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7)
|
||||||
if (Loc) {
|
if (Loc) {
|
||||||
|
|
||||||
StringRef instFilename;
|
StringRef instFilename;
|
||||||
DILocation *cDILoc = dyn_cast<DILocation>(Loc.getAsMDNode());
|
DILocation *cDILoc = dyn_cast<DILocation>(Loc.getAsMDNode());
|
||||||
|
|
||||||
if (cDILoc) {
|
if (cDILoc) { instFilename = cDILoc->getFilename(); }
|
||||||
|
|
||||||
instFilename = cDILoc->getFilename();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instFilename.str().empty()) {
|
if (instFilename.str().empty()) {
|
||||||
|
|
||||||
|
@ -379,11 +379,9 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
else
|
else
|
||||||
Str1 = TmpStr.str();
|
Str1 = TmpStr.str();
|
||||||
bool HasStr2 = getConstantStringInfo(Str2P, TmpStr);
|
bool HasStr2 = getConstantStringInfo(Str2P, TmpStr);
|
||||||
if (TmpStr.empty())
|
if (TmpStr.empty()) HasStr2 = false;
|
||||||
HasStr2 = false;
|
(void)HasStr2 /* never read */
|
||||||
(void) HasStr2 /* never read */
|
else Str2 = TmpStr.str();
|
||||||
else
|
|
||||||
Str2 = TmpStr.str();
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
fprintf(stderr, "F:%s %p(%s)->\"%s\"(%s) %p(%s)->\"%s\"(%s)\n",
|
fprintf(stderr, "F:%s %p(%s)->\"%s\"(%s) %p(%s)->\"%s\"(%s)\n",
|
||||||
|
@ -1843,7 +1843,8 @@ void setup_stdio_file(afl_state_t *afl) {
|
|||||||
|
|
||||||
if (afl->file_extension) {
|
if (afl->file_extension) {
|
||||||
|
|
||||||
afl->fsrv.out_file = alloc_printf("%s/.cur_input.%s", afl->tmp_dir, afl->file_extension);
|
afl->fsrv.out_file =
|
||||||
|
alloc_printf("%s/.cur_input.%s", afl->tmp_dir, afl->file_extension);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -1851,11 +1852,15 @@ void setup_stdio_file(afl_state_t *afl) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink(afl->fsrv.out_file); /* Ignore errors */
|
unlink(afl->fsrv.out_file); /* Ignore errors */
|
||||||
|
|
||||||
afl->fsrv.out_fd = open(afl->fsrv.out_file, O_RDWR | O_CREAT | O_EXCL, 0600);
|
afl->fsrv.out_fd = open(afl->fsrv.out_file, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
|
|
||||||
if (afl->fsrv.out_fd < 0) { PFATAL("Unable to create '%s'", afl->fsrv.out_file); }
|
if (afl->fsrv.out_fd < 0) {
|
||||||
|
|
||||||
|
PFATAL("Unable to create '%s'", afl->fsrv.out_file);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user