about summary refs log tree commit diff
path: root/src/afl-fuzz.c
diff options
context:
space:
mode:
authorRishi Ranjan <43873720+rish9101@users.noreply.github.com>2020-03-15 22:59:23 +0530
committerGitHub <noreply@github.com>2020-03-15 18:29:23 +0100
commit126d1f1cd14c6bb1fb59159965045f02d98d1b43 (patch)
tree64a12fc2222b766087f0edfd63c30acf27c19cf4 /src/afl-fuzz.c
parent7685893cdbfd621b09b57a11c135347f692333cc (diff)
downloadafl++-126d1f1cd14c6bb1fb59159965045f02d98d1b43.tar.gz
Move afl-fuzz related env variables into afl_state_t (#252)
* Move afl-fuzz related env variables into afl_state_t

* Move the env variables assignment from fuzz_init and code Format

* Fix typo

* Remove redundant env variables from afl_env struct

* Rename function to read_afl_environment
Diffstat (limited to 'src/afl-fuzz.c')
-rw-r--r--src/afl-fuzz.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 63a0af0f..ad619b1e 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -245,6 +245,8 @@ int main(int argc, char **argv_orig, char **envp) {
   afl_state_init(afl);
   afl_fsrv_init(&afl->fsrv);
 
+  read_afl_environment(afl, envp);
+
   SAYF(cCYA "afl-fuzz" VERSION cRST
             " based on afl by Michal Zalewski and a big online community\n");
 
@@ -472,7 +474,7 @@ int main(int argc, char **argv_orig, char **envp) {
       case 'n':                                                /* dumb mode */
 
         if (afl->dumb_mode) FATAL("Multiple -n options not supported");
-        if (get_afl_env("AFL_DUMB_FORKSRV"))
+        if (afl->afl_env.afl_dumb_forksrv)
           afl->dumb_mode = 2;
         else
           afl->dumb_mode = 1;
@@ -681,8 +683,6 @@ int main(int argc, char **argv_orig, char **envp) {
         "Using -M master with the AFL_CUSTOM_MUTATOR_ONLY mutator options will "
         "result in no deterministic mutations being done!");
 
-  check_environment_vars(envp);
-
   if (afl->fixed_seed) OKF("Running with fixed seed: %u", (u32)afl->init_seed);
   srandom((u32)afl->init_seed);
 
@@ -768,16 +768,16 @@ int main(int argc, char **argv_orig, char **envp) {
   if (get_afl_env("AFL_SHUFFLE_QUEUE")) afl->shuffle_queue = 1;
   if (get_afl_env("AFL_FAST_CAL")) afl->fast_cal = 1;
 
-  if (get_afl_env("AFL_AUTORESUME")) {
+  if (afl->afl_env.afl_autoresume) {
 
     afl->autoresume = 1;
     if (afl->in_place_resume) SAYF("AFL_AUTORESUME has no effect for '-i -'");
 
   }
 
-  if (get_afl_env("AFL_HANG_TMOUT")) {
+  if (afl->afl_env.afl_hang_tmout) {
 
-    afl->hang_tmout = atoi(getenv("AFL_HANG_TMOUT"));
+    afl->hang_tmout = atoi(afl->afl_env.afl_hang_tmout);
     if (!afl->hang_tmout) FATAL("Invalid value of AFL_HANG_TMOUT");
 
   }
@@ -792,7 +792,7 @@ int main(int argc, char **argv_orig, char **envp) {
         "LD_PRELOAD is set, are you sure that is what to you want to do "
         "instead of using AFL_PRELOAD?");
 
-  if (get_afl_env("AFL_PRELOAD")) {
+  if (afl->afl_env.afl_preload) {
 
     if (afl->qemu_mode) {
 
@@ -838,7 +838,7 @@ int main(int argc, char **argv_orig, char **envp) {
   fix_up_banner(afl, argv[optind]);
 
   check_if_tty(afl);
-  if (get_afl_env("AFL_FORCE_UI")) afl->not_on_tty = 0;
+  if (afl->afl_env.afl_force_ui) afl->not_on_tty = 0;
 
   if (get_afl_env("AFL_CAL_FAST")) {
 
@@ -850,7 +850,7 @@ int main(int argc, char **argv_orig, char **envp) {
 
   if (get_afl_env("AFL_DEBUG")) afl->debug = 1;
 
-  if (get_afl_env("AFL_CUSTOM_MUTATOR_ONLY")) {
+  if (afl->afl_env.afl_custom_mutator_only) {
 
     /* This ensures we don't proceed to havoc/splice */
     afl->custom_only = 1;
@@ -894,7 +894,7 @@ int main(int argc, char **argv_orig, char **envp) {
 
   if (!afl->timeout_given) find_timeout(afl);
 
-  if ((afl->tmp_dir = get_afl_env("AFL_TMPDIR")) != NULL &&
+  if ((afl->tmp_dir = afl->afl_env.afl_tmpdir) != NULL &&
       !afl->in_place_resume) {
 
     char tmpfile[afl->file_extension ? strlen(afl->tmp_dir) + 1 + 10 + 1 +
@@ -1067,7 +1067,7 @@ int main(int argc, char **argv_orig, char **envp) {
       prev_queued = afl->queued_paths;
 
       if (afl->sync_id && afl->queue_cycle == 1 &&
-          get_afl_env("AFL_IMPORT_FIRST"))
+          afl->afl_env.afl_import_first)
         sync_fuzzers(afl);
 
     }