aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-02-18 21:41:28 +0100
committervan Hauser <vh@thc.org>2020-02-18 21:41:28 +0100
commitecce840eca6816da3c7c39d3bf6f74c9626294f7 (patch)
tree1b91a18b67d19c074cbfaa1a2d1f3063ba505b47
parent273e3aed10b50eb73a0d3fde37858c545d8dc702 (diff)
downloadafl++-ecce840eca6816da3c7c39d3bf6f74c9626294f7.tar.gz
moved AFL_TMPDIR check further down and better error message
-rw-r--r--src/afl-fuzz.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 1feb96be..740fb5cb 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -654,25 +654,6 @@ int main(int argc, char** argv, char** envp) {
if (!strcmp(in_dir, out_dir))
FATAL("Input and output directories can't be the same");
- if ((tmp_dir = getenv("AFL_TMPDIR")) != NULL && !in_place_resume) {
-
- char tmpfile[file_extension
- ? strlen(tmp_dir) + 1 + 10 + 1 + strlen(file_extension) + 1
- : strlen(tmp_dir) + 1 + 10 + 1];
- if (file_extension) {
- sprintf(tmpfile, "%s/.cur_input.%s", tmp_dir, file_extension);
- } else {
- sprintf(tmpfile, "%s/.cur_input", tmp_dir);
- }
- if (access(tmpfile, F_OK) !=
- -1) // there is still a race condition here, but well ...
- FATAL("AFL_TMPDIR already has an existing temporary input file: %s",
- tmpfile);
-
- } else
-
- tmp_dir = out_dir;
-
if (dumb_mode) {
if (crash_mode) FATAL("-C and -n are mutually exclusive");
@@ -846,6 +827,26 @@ int main(int argc, char** argv, char** envp) {
if (!timeout_given) find_timeout();
+ if ((tmp_dir = getenv("AFL_TMPDIR")) != NULL && !in_place_resume) {
+
+ char tmpfile[file_extension
+ ? strlen(tmp_dir) + 1 + 10 + 1 + strlen(file_extension) + 1
+ : strlen(tmp_dir) + 1 + 10 + 1];
+ if (file_extension) {
+ sprintf(tmpfile, "%s/.cur_input.%s", tmp_dir, file_extension);
+ } else {
+ sprintf(tmpfile, "%s/.cur_input", tmp_dir);
+ }
+ if (access(tmpfile, F_OK) !=
+ -1) // there is still a race condition here, but well ...
+ FATAL("AFL_TMPDIR already has an existing temporary input file: %s - if this is not from another instance, then just remove the file.",
+ tmpfile);
+
+ } else
+
+ tmp_dir = out_dir;
+
+
/* If we don't have a file name chosen yet, use a safe default. */
if (!out_file) {