aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-04-27 22:12:56 +0200
committerGitHub <noreply@github.com>2020-04-27 22:12:56 +0200
commitc7de368dc20078116bcb2e34b0f2237127802841 (patch)
treeb5ffdea8bd04d179c79fcaca9774e177bbc6e219
parenta5d4c8d532263f13e0036b55dfbbbf302ec0766f (diff)
parentfbd9994f6f959def9c228b81711706bbc5be8cde (diff)
downloadafl++-c7de368dc20078116bcb2e34b0f2237127802841.tar.gz
Merge pull request #342 from AFLplusplus/dev
fix for afl-showmap with -Q
-rw-r--r--GNUmakefile2
-rw-r--r--docs/Changelog.md1
-rw-r--r--src/afl-showmap.c28
3 files changed, 15 insertions, 16 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 8811da03..8ea64109 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -341,7 +341,7 @@ src/third_party/libradamsa/libradamsa.so: src/third_party/libradamsa/libradamsa.
afl-fuzz: $(COMM_HDR) include/afl-fuzz.h $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o | test_x86
$(CC) $(CFLAGS) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(PYFLAGS) $(LDFLAGS)
-afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o $(COMM_HDR) | test_x86
+afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o $(COMM_HDR) | test_x86
$(CC) $(CFLAGS) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(LDFLAGS)
afl-tmin: src/afl-tmin.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o $(COMM_HDR) | test_x86
diff --git a/docs/Changelog.md b/docs/Changelog.md
index da28ce53..dadfa7e0 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -27,6 +27,7 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
- better dependency checks
- unicorn_mode:
- better submodule handling
+ - afl-showmap: fix for -Q mode
- all:
- forkserver communication now also used for error reporting
- fix 32 bit build options
diff --git a/src/afl-showmap.c b/src/afl-showmap.c
index af6c2b1a..a51d520d 100644
--- a/src/afl-showmap.c
+++ b/src/afl-showmap.c
@@ -714,7 +714,6 @@ int main(int argc, char **argv_orig, char **envp) {
case 'Q':
if (fsrv->qemu_mode) { FATAL("Multiple -Q options not supported"); }
- if (!mem_limit_given) { fsrv->mem_limit = MEM_LIMIT_QEMU; }
fsrv->qemu_mode = 1;
break;
@@ -722,7 +721,6 @@ int main(int argc, char **argv_orig, char **envp) {
case 'U':
if (unicorn_mode) { FATAL("Multiple -U options not supported"); }
- if (!mem_limit_given) { fsrv->mem_limit = MEM_LIMIT_UNICORN; }
unicorn_mode = 1;
break;
@@ -733,8 +731,6 @@ int main(int argc, char **argv_orig, char **envp) {
fsrv->qemu_mode = 1;
use_wine = 1;
- if (!mem_limit_given) { fsrv->mem_limit = 0; }
-
break;
case 'b':
@@ -772,6 +768,9 @@ int main(int argc, char **argv_orig, char **envp) {
if (optind == argc || !out_file) { usage(argv[0]); }
+ if (fsrv->qemu_mode && !mem_limit_given) { fsrv->mem_limit = MEM_LIMIT_QEMU; }
+ if (unicorn_mode && !mem_limit_given) { fsrv->mem_limit = MEM_LIMIT_UNICORN; }
+
check_environment_vars(envp);
sharedmem_t shm = {0};
@@ -800,12 +799,6 @@ int main(int argc, char **argv_orig, char **envp) {
}
- for (i = optind; i < argc; i++) {
-
- if (strcmp(argv[i], "@@") == 0) { arg_offset = i; }
-
- }
-
if (fsrv->qemu_mode) {
if (use_wine) {
@@ -826,6 +819,14 @@ int main(int argc, char **argv_orig, char **envp) {
}
+ i = 0;
+ while (use_argv[i] != NULL && !arg_offset) {
+
+ if (strcmp(use_argv[i], "@@") == 0) { arg_offset = i; }
+ i++;
+
+ }
+
if (in_dir) {
DIR * dir_in, *dir_out;
@@ -870,10 +871,9 @@ int main(int argc, char **argv_orig, char **envp) {
fsrv->out_fd = open(stdin_file, O_RDWR | O_CREAT | O_EXCL, 0600);
if (fsrv->out_fd < 0) { PFATAL("Unable to create '%s'", out_file); }
- if (arg_offset && argv[arg_offset] != stdin_file) {
+ if (arg_offset && use_argv[arg_offset] != stdin_file) {
- ck_free(argv[arg_offset]);
- argv[arg_offset] = strdup(stdin_file);
+ use_argv[arg_offset] = strdup(stdin_file);
}
@@ -888,8 +888,6 @@ int main(int argc, char **argv_orig, char **envp) {
}
SAYF("\n");
- SAYF(cMGN "[D]" cRST " %d - %d = %d, %s\n", arg_offset, optind,
- arg_offset - optind, infile);
}