mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-14 19:08:08 +00:00
fix endless loop in afl-cc allow/blocklists starting a line with a comment
This commit is contained in:
@ -10,9 +10,13 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
|
|||||||
|
|
||||||
|
|
||||||
### Version ++3.01a (release)
|
### Version ++3.01a (release)
|
||||||
- fix crash for very, very fast targets+systems, thanks for reporting @mhlakhani
|
- fix crash for very, very fast targets+systems (thanks to mhlakhani
|
||||||
|
for reporting)
|
||||||
- added dummy Makefile to instrumentation/
|
- added dummy Makefile to instrumentation/
|
||||||
|
- afl-cc
|
||||||
- allow instrumenting LLVMFuzzerTestOneInput
|
- allow instrumenting LLVMFuzzerTestOneInput
|
||||||
|
- fixed endless loop for allow/blocklist lines starting with a
|
||||||
|
comment (thanks to Zherya for reporting)
|
||||||
|
|
||||||
|
|
||||||
### Version ++3.00c (release)
|
### Version ++3.00c (release)
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
******************************************************/
|
******************************************************/
|
||||||
|
|
||||||
/* console output colors: There are three ways to configure its behavior
|
/* console output colors: There are three ways to configure its behavior
|
||||||
* 1. default: colored outputs fixed on: defined USE_COLOR && defined ALWAYS_COLORED
|
* 1. default: colored outputs fixed on: defined USE_COLOR && defined
|
||||||
* The env var. AFL_NO_COLOR will have no effect
|
* ALWAYS_COLORED The env var. AFL_NO_COLOR will have no effect
|
||||||
* 2. defined USE_COLOR && !defined ALWAYS_COLORED
|
* 2. defined USE_COLOR && !defined ALWAYS_COLORED
|
||||||
* -> depending on env var AFL_NO_COLOR=1 colors can be switched off
|
* -> depending on env var AFL_NO_COLOR=1 colors can be switched off
|
||||||
* at run-time. Default is to use colors.
|
* at run-time. Default is to use colors.
|
||||||
@ -53,7 +53,8 @@
|
|||||||
|
|
||||||
#ifdef USE_COLOR
|
#ifdef USE_COLOR
|
||||||
/* Comment in to always enable terminal colors */
|
/* Comment in to always enable terminal colors */
|
||||||
/* Comment out to enable runtime controlled terminal colors via AFL_NO_COLOR */
|
/* Comment out to enable runtime controlled terminal colors via AFL_NO_COLOR
|
||||||
|
*/
|
||||||
#define ALWAYS_COLORED 1
|
#define ALWAYS_COLORED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -172,17 +172,23 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#pragma GCC diagnostic ignored "-Wformat-security"
|
#pragma GCC diagnostic ignored "-Wformat-security"
|
||||||
static inline const char *colorfilter(const char *x) {
|
static inline const char *colorfilter(const char *x) {
|
||||||
|
|
||||||
static int once = 1;
|
static int once = 1;
|
||||||
static int disabled = 0;
|
static int disabled = 0;
|
||||||
|
|
||||||
if (once) {
|
if (once) {
|
||||||
|
|
||||||
/* when there is no tty -> we always want filtering
|
/* when there is no tty -> we always want filtering
|
||||||
* when AFL_NO_UI is set filtering depends on AFL_NO_COLOR
|
* when AFL_NO_UI is set filtering depends on AFL_NO_COLOR
|
||||||
* otherwise we want always colors
|
* otherwise we want always colors
|
||||||
*/
|
*/
|
||||||
disabled = isatty(2) && (!getenv("AFL_NO_UI") || (!getenv("AFL_NO_COLOR") && !getenv("AFL_NO_COLOUR")));
|
disabled =
|
||||||
|
isatty(2) && (!getenv("AFL_NO_UI") ||
|
||||||
|
(!getenv("AFL_NO_COLOR") && !getenv("AFL_NO_COLOUR")));
|
||||||
once = 0;
|
once = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (likely(disabled)) return x;
|
if (likely(disabled)) return x;
|
||||||
|
|
||||||
static char monochromestring[4096];
|
static char monochromestring[4096];
|
||||||
@ -190,41 +196,47 @@ static inline const char * colorfilter(const char * x) {
|
|||||||
int in_seq = 0;
|
int in_seq = 0;
|
||||||
|
|
||||||
while (*x) {
|
while (*x) {
|
||||||
|
|
||||||
if (in_seq && *x == 'm') {
|
if (in_seq && *x == 'm') {
|
||||||
|
|
||||||
in_seq = 0;
|
in_seq = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (!in_seq && *x == '\x1b') { in_seq = 1; }
|
if (!in_seq && *x == '\x1b') { in_seq = 1; }
|
||||||
if (!in_seq) {
|
if (!in_seq) { *d++ = *x; }
|
||||||
*d++ = *x;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++x;
|
++x;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*d = '\0';
|
*d = '\0';
|
||||||
return monochromestring;
|
return monochromestring;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define colorfilter(x) x /* no filtering necessary */
|
#define colorfilter(x) x /* no filtering necessary */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* macro magic to transform the first parameter to SAYF
|
/* macro magic to transform the first parameter to SAYF
|
||||||
* through colorfilter which strips coloring */
|
* through colorfilter which strips coloring */
|
||||||
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,\
|
#define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
|
||||||
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,\
|
_15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, \
|
||||||
_21,_22,_23,_24,_25,_26,_27,_28,_29,_30,\
|
_27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, \
|
||||||
_31,_32,_33,_34,_35,_36,_37,_38,_39,_40,\
|
_39, _40, NAME, ...) \
|
||||||
NAME,...) NAME
|
NAME
|
||||||
|
|
||||||
#define SAYF(...) GET_MACRO(__VA_ARGS__, \
|
#define SAYF(...) \
|
||||||
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
GET_MACRO(__VA_ARGS__, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
||||||
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
||||||
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
||||||
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
||||||
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
||||||
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
SAYF_N, SAYF_1) \
|
||||||
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_N, \
|
(__VA_ARGS__)
|
||||||
SAYF_N, SAYF_N, SAYF_N, SAYF_N, SAYF_1)(__VA_ARGS__)
|
|
||||||
|
|
||||||
#define SAYF_1(x) MY_SAYF(colorfilter(x))
|
#define SAYF_1(x) MY_SAYF(colorfilter(x))
|
||||||
#define SAYF_N(x, ...) MY_SAYF(colorfilter(x), __VA_ARGS__)
|
#define SAYF_N(x, ...) MY_SAYF(colorfilter(x), __VA_ARGS__)
|
||||||
|
@ -78,8 +78,8 @@ static char *afl_environment_variables[] = {
|
|||||||
"AFL_LLVM_CTX",
|
"AFL_LLVM_CTX",
|
||||||
"AFL_LLVM_DICT2FILE",
|
"AFL_LLVM_DICT2FILE",
|
||||||
"AFL_LLVM_DOCUMENT_IDS",
|
"AFL_LLVM_DOCUMENT_IDS",
|
||||||
"AFL_LLVM_INSTRUMENT",
|
|
||||||
"AFL_LLVM_INSTRIM_LOOPHEAD",
|
"AFL_LLVM_INSTRIM_LOOPHEAD",
|
||||||
|
"AFL_LLVM_INSTRUMENT",
|
||||||
"AFL_LLVM_LTO_AUTODICTIONARY",
|
"AFL_LLVM_LTO_AUTODICTIONARY",
|
||||||
"AFL_LLVM_AUTODICTIONARY",
|
"AFL_LLVM_AUTODICTIONARY",
|
||||||
"AFL_LLVM_SKIPSINGLEBLOCK",
|
"AFL_LLVM_SKIPSINGLEBLOCK",
|
||||||
|
@ -622,10 +622,11 @@ struct afl_pass : gimple_opt_pass {
|
|||||||
allowListFiles.push_back(line);
|
allowListFiles.push_back(line);
|
||||||
else
|
else
|
||||||
allowListFunctions.push_back(line);
|
allowListFunctions.push_back(line);
|
||||||
getline(fileStream, line);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getline(fileStream, line);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -696,10 +697,11 @@ struct afl_pass : gimple_opt_pass {
|
|||||||
denyListFiles.push_back(line);
|
denyListFiles.push_back(line);
|
||||||
else
|
else
|
||||||
denyListFunctions.push_back(line);
|
denyListFunctions.push_back(line);
|
||||||
getline(fileStream, line);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getline(fileStream, line);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -168,10 +168,11 @@ void initInstrumentList() {
|
|||||||
allowListFiles.push_back(line);
|
allowListFiles.push_back(line);
|
||||||
else
|
else
|
||||||
allowListFunctions.push_back(line);
|
allowListFunctions.push_back(line);
|
||||||
getline(fileStream, line);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getline(fileStream, line);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -242,10 +243,11 @@ void initInstrumentList() {
|
|||||||
denyListFiles.push_back(line);
|
denyListFiles.push_back(line);
|
||||||
else
|
else
|
||||||
denyListFunctions.push_back(line);
|
denyListFunctions.push_back(line);
|
||||||
getline(fileStream, line);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getline(fileStream, line);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -1432,7 +1432,7 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
" AFL_LLVM_LAF_SPLIT_FLOATS: cascaded comparisons on floats\n"
|
" AFL_LLVM_LAF_SPLIT_FLOATS: cascaded comparisons on floats\n"
|
||||||
" AFL_LLVM_LAF_TRANSFORM_COMPARES: cascade comparisons for string "
|
" AFL_LLVM_LAF_TRANSFORM_COMPARES: cascade comparisons for string "
|
||||||
"functions\n"
|
"functions\n"
|
||||||
" AFL_LLVM_INSTRUMENT_ALLOW/AFL_LLVM_INSTRUMENT_DENY: enable "
|
" AFL_LLVM_ALLOWLIST/AFL_LLVM_DENYLIST: enable "
|
||||||
"instrument allow/\n"
|
"instrument allow/\n"
|
||||||
" deny listing (selective instrumentation)\n");
|
" deny listing (selective instrumentation)\n");
|
||||||
|
|
||||||
|
@ -402,6 +402,7 @@ void read_afl_environment(afl_state_t *afl, char **envp) {
|
|||||||
(u8 *)get_afl_env(afl_environment_variables[i]);
|
(u8 *)get_afl_env(afl_environment_variables[i]);
|
||||||
|
|
||||||
#if defined USE_COLOR && !defined ALWAYS_COLORED
|
#if defined USE_COLOR && !defined ALWAYS_COLORED
|
||||||
|
|
||||||
} else if (!strncmp(env, "AFL_NO_COLOR",
|
} else if (!strncmp(env, "AFL_NO_COLOR",
|
||||||
|
|
||||||
afl_environment_variable_len)) {
|
afl_environment_variable_len)) {
|
||||||
|
@ -157,7 +157,8 @@ static void usage(u8 *argv0, int more_help) {
|
|||||||
if (more_help > 1) {
|
if (more_help > 1) {
|
||||||
|
|
||||||
#if defined USE_COLOR && !defined ALWAYS_COLORED
|
#if defined USE_COLOR && !defined ALWAYS_COLORED
|
||||||
#define DYN_COLOR "AFL_NO_COLOR or AFL_NO_COLOUR: switch colored console output off\n"
|
#define DYN_COLOR \
|
||||||
|
"AFL_NO_COLOR or AFL_NO_COLOUR: switch colored console output off\n"
|
||||||
#else
|
#else
|
||||||
#define DYN_COLOR
|
#define DYN_COLOR
|
||||||
#endif
|
#endif
|
||||||
@ -309,8 +310,13 @@ int main(int argc, char **argv_orig, char **envp) {
|
|||||||
|
|
||||||
#if defined USE_COLOR && defined ALWAYS_COLORED
|
#if defined USE_COLOR && defined ALWAYS_COLORED
|
||||||
if (getenv("AFL_NO_COLOR") || getenv("AFL_NO_COLOUR")) {
|
if (getenv("AFL_NO_COLOR") || getenv("AFL_NO_COLOUR")) {
|
||||||
WARNF("Setting AFL_NO_COLOR has no effect (colors are configured on at compile time)");
|
|
||||||
|
WARNF(
|
||||||
|
"Setting AFL_NO_COLOR has no effect (colors are configured on at "
|
||||||
|
"compile time)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char **argv = argv_cpy_dup(argc, argv_orig);
|
char **argv = argv_cpy_dup(argc, argv_orig);
|
||||||
|
Reference in New Issue
Block a user