aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2024-03-15 08:39:39 +0700
committerGitHub <noreply@github.com>2024-03-15 08:39:39 +0700
commita96bda82f9f5756995e4cfa9886fcc2a31b2819d (patch)
tree9c921260dc7916f5cbc2b7bac95e5ab99a072ec9
parent93c7a42453ff356a3e787e662794e2b43b260158 (diff)
parent1860f6e594883965f7b630a65d5a77006f284aa1 (diff)
downloadafl++-a96bda82f9f5756995e4cfa9886fcc2a31b2819d.tar.gz
Merge pull request #2033 from gnbon/stable
Add -l option for adjustable block deletion performance in tmin
-rw-r--r--src/afl-tmin.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/afl-tmin.c b/src/afl-tmin.c
index 4e5dab41..994174ed 100644
--- a/src/afl-tmin.c
+++ b/src/afl-tmin.c
@@ -82,6 +82,8 @@ static u8 crash_mode, /* Crash-centric mode? */
remove_shm = 1, /* remove shmem on exit? */
debug; /* debug mode */
+static u32 del_len_limit = 1; /* Minimum block deletion length */
+
static volatile u8 stop_soon; /* Ctrl-C pressed? */
static afl_forkserver_t *fsrv;
@@ -480,7 +482,7 @@ next_del_blksize:
}
- if (del_len > 1 && in_len >= 1) {
+ if (del_len > del_len_limit && in_len >= 1) {
del_len /= 2;
goto next_del_blksize;
@@ -796,8 +798,9 @@ static void usage(u8 *argv0) {
"Minimization settings:\n"
" -e - solve for edge coverage only, ignore hit counts\n"
- " -x - treat non-zero exit codes as crashes\n\n"
- " -H - minimize a hang (hang mode)\n"
+ " -l bytes - set minimum block deletion length to speed up minimization\n"
+ " -x - treat non-zero exit codes as crashes\n"
+ " -H - minimize a hang (hang mode)\n\n"
"For additional tips, please consult %s/README.md.\n\n"
@@ -829,8 +832,9 @@ static void usage(u8 *argv0) {
int main(int argc, char **argv_orig, char **envp) {
- s32 opt;
- u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0;
+ s32 opt;
+ u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0,
+ del_limit_given = 0;
char **use_argv;
char **argv = argv_cpy_dup(argc, argv_orig);
@@ -846,7 +850,7 @@ int main(int argc, char **argv_orig, char **envp) {
SAYF(cCYA "afl-tmin" VERSION cRST " by Michal Zalewski\n");
- while ((opt = getopt(argc, argv, "+i:o:f:m:t:B:xeAOQUWXYHh")) > 0) {
+ while ((opt = getopt(argc, argv, "+i:o:f:m:t:l:B:xeAOQUWXYHh")) > 0) {
switch (opt) {
@@ -1055,6 +1059,24 @@ int main(int argc, char **argv_orig, char **envp) {
read_bitmap(optarg, mask_bitmap, map_size);
break;
+ case 'l':
+ if (del_limit_given) { FATAL("Multiple -l options not supported"); }
+ del_limit_given = 1;
+
+ if (!optarg) { FATAL("Wrong usage of -l"); }
+
+ if (optarg[0] == '-') { FATAL("Dangerously low value of -l"); }
+
+ del_len_limit = atoi(optarg);
+
+ if (del_len_limit < 1 || del_len_limit > TMIN_MAX_FILE) {
+
+ FATAL("Value of -l out of range between 1 and TMIN_MAX_FILE");
+
+ }
+
+ break;
+
case 'h':
usage(argv[0]);
return -1;