Skip to content

Commit c7de368

Browse files
Merge pull request AFLplusplus#342 from AFLplusplus/dev
fix for afl-showmap with -Q
2 parents a5d4c8d + fbd9994 commit c7de368

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ src/third_party/libradamsa/libradamsa.so: src/third_party/libradamsa/libradamsa.
341341
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
342342
$(CC) $(CFLAGS) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(PYFLAGS) $(LDFLAGS)
343343

344-
afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o $(COMM_HDR) | test_x86
344+
afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o $(COMM_HDR) | test_x86
345345
$(CC) $(CFLAGS) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(LDFLAGS)
346346

347347
afl-tmin: src/afl-tmin.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o $(COMM_HDR) | test_x86

docs/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ sending a mail to <[email protected]>.
2727
- better dependency checks
2828
- unicorn_mode:
2929
- better submodule handling
30+
- afl-showmap: fix for -Q mode
3031
- all:
3132
- forkserver communication now also used for error reporting
3233
- fix 32 bit build options

src/afl-showmap.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,13 @@ int main(int argc, char **argv_orig, char **envp) {
714714
case 'Q':
715715

716716
if (fsrv->qemu_mode) { FATAL("Multiple -Q options not supported"); }
717-
if (!mem_limit_given) { fsrv->mem_limit = MEM_LIMIT_QEMU; }
718717

719718
fsrv->qemu_mode = 1;
720719
break;
721720

722721
case 'U':
723722

724723
if (unicorn_mode) { FATAL("Multiple -U options not supported"); }
725-
if (!mem_limit_given) { fsrv->mem_limit = MEM_LIMIT_UNICORN; }
726724

727725
unicorn_mode = 1;
728726
break;
@@ -733,8 +731,6 @@ int main(int argc, char **argv_orig, char **envp) {
733731
fsrv->qemu_mode = 1;
734732
use_wine = 1;
735733

736-
if (!mem_limit_given) { fsrv->mem_limit = 0; }
737-
738734
break;
739735

740736
case 'b':
@@ -772,6 +768,9 @@ int main(int argc, char **argv_orig, char **envp) {
772768

773769
if (optind == argc || !out_file) { usage(argv[0]); }
774770

771+
if (fsrv->qemu_mode && !mem_limit_given) { fsrv->mem_limit = MEM_LIMIT_QEMU; }
772+
if (unicorn_mode && !mem_limit_given) { fsrv->mem_limit = MEM_LIMIT_UNICORN; }
773+
775774
check_environment_vars(envp);
776775

777776
sharedmem_t shm = {0};
@@ -800,12 +799,6 @@ int main(int argc, char **argv_orig, char **envp) {
800799

801800
}
802801

803-
for (i = optind; i < argc; i++) {
804-
805-
if (strcmp(argv[i], "@@") == 0) { arg_offset = i; }
806-
807-
}
808-
809802
if (fsrv->qemu_mode) {
810803

811804
if (use_wine) {
@@ -826,6 +819,14 @@ int main(int argc, char **argv_orig, char **envp) {
826819

827820
}
828821

822+
i = 0;
823+
while (use_argv[i] != NULL && !arg_offset) {
824+
825+
if (strcmp(use_argv[i], "@@") == 0) { arg_offset = i; }
826+
i++;
827+
828+
}
829+
829830
if (in_dir) {
830831

831832
DIR * dir_in, *dir_out;
@@ -870,10 +871,9 @@ int main(int argc, char **argv_orig, char **envp) {
870871
fsrv->out_fd = open(stdin_file, O_RDWR | O_CREAT | O_EXCL, 0600);
871872
if (fsrv->out_fd < 0) { PFATAL("Unable to create '%s'", out_file); }
872873

873-
if (arg_offset && argv[arg_offset] != stdin_file) {
874+
if (arg_offset && use_argv[arg_offset] != stdin_file) {
874875

875-
ck_free(argv[arg_offset]);
876-
argv[arg_offset] = strdup(stdin_file);
876+
use_argv[arg_offset] = strdup(stdin_file);
877877

878878
}
879879

@@ -888,8 +888,6 @@ int main(int argc, char **argv_orig, char **envp) {
888888
}
889889

890890
SAYF("\n");
891-
SAYF(cMGN "[D]" cRST " %d - %d = %d, %s\n", arg_offset, optind,
892-
arg_offset - optind, infile);
893891

894892
}
895893

0 commit comments

Comments
 (0)