aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-10-14 17:32:51 +0200
committervan Hauser <vh@thc.org>2020-10-14 17:32:51 +0200
commit735e8c39561d3d4d8bae01251e025e52e05472e2 (patch)
treea6459670af7bdf8cbb42a2ee2d548401b827e10a
parent23872d6f2c0ae77beb832f44d392f86cc8530e1a (diff)
downloadafl++-735e8c39561d3d4d8bae01251e025e52e05472e2.tar.gz
check for minimum cache size
-rw-r--r--include/afl-fuzz.h2
-rw-r--r--src/afl-fuzz.c21
2 files changed, 17 insertions, 6 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index 514d558b..8bac1457 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -1165,7 +1165,7 @@ void queue_testcase_retake(afl_state_t *afl, struct queue_entry *q,
u32 old_len);
#if TESTCASE_CACHE == 1
-#error define of TESTCASE_CACHE must be zero or larger than 1
+ #error define of TESTCASE_CACHE must be zero or larger than 1
#endif
#endif
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index a59abb7d..3167b742 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -200,8 +200,8 @@ static void usage(u8 *argv0, int more_help) {
"AFL_STATSD_HOST: change default statsd host (default 127.0.0.1)\n"
"AFL_STATSD_PORT: change default statsd port (default: 8125)\n"
"AFL_STATSD_TAGS_FLAVOR: set statsd tags format (default: disable tags)\n"
- " Supported formats are: 'dogstatsd', 'librato', 'signalfx'\n"
- " and 'influxdb'\n"
+ " Supported formats are: 'dogstatsd', 'librato',\n"
+ " 'signalfx' and 'influxdb'\n"
"AFL_TESTCACHE_SIZE: use a cache for testcases, improves performance (in MB)\n"
"AFL_TMPDIR: directory to use for input file generation (ramdisk recommended)\n"
//"AFL_PERSISTENT: not supported anymore -> no effect, just a warning\n"
@@ -1012,15 +1012,26 @@ int main(int argc, char **argv_orig, char **envp) {
afl->q_testcase_max_cache_size =
(u64)atoi(afl->afl_env.afl_testcache_size) * 1024000;
- OKF("Enabled testcache with %llu MB",
- afl->q_testcase_max_cache_size / 1024000);
- } else {
+ }
+
+ if (!afl->q_testcase_max_cache_size) {
ACTF(
"No testcache was configured. it is recommended to use a testcache, it "
"improves performance: set AFL_TESTCACHE_SIZE=(value in MB)");
+ } else if (afl->q_testcase_max_cache_size < 2 * MAX_FILE) {
+
+ FATAL("AFL_TESTCACHE_SIZE must be set to %u or more, or 0 to disable",
+ (2 * MAX_FILE) % 1024000 ? 1 + ((2 * MAX_FILE) / 1024000)
+ : (2 * MAX_FILE) / 1024000);
+
+ } else {
+
+ OKF("Enabled testcache with %llu MB",
+ afl->q_testcase_max_cache_size / 1024000);
+
}
if (afl->afl_env.afl_forksrv_init_tmout) {