about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEdznux <edznux@gmail.com>2020-10-05 22:01:50 +0200
committerEdznux <edznux@gmail.com>2020-10-05 22:01:50 +0200
commit2bf3a70e2b5cd0961cb5b1d525f3fd58c4408ba5 (patch)
treefe197e9032f28e41648a45372c20e82dc10b36c6 /src
parent9b112fde1a7d776b07f0cb656d11c6151902d2c3 (diff)
downloadafl++-2bf3a70e2b5cd0961cb5b1d525f3fd58c4408ba5.tar.gz
Correctly handle env var.
Diffstat (limited to 'src')
-rw-r--r--src/afl-fuzz-state.c13
-rw-r--r--src/afl-fuzz-statsd.c6
2 files changed, 15 insertions, 4 deletions
diff --git a/src/afl-fuzz-state.c b/src/afl-fuzz-state.c
index 4e817843..aefa226d 100644
--- a/src/afl-fuzz-state.c
+++ b/src/afl-fuzz-state.c
@@ -363,6 +363,19 @@ void read_afl_environment(afl_state_t *afl, char **envp) {
             afl->afl_env.afl_forksrv_init_tmout =
                 (u8 *)get_afl_env(afl_environment_variables[i]);
 
+          } else if (!strncmp(env, "AFL_STATSD_HOST",
+
+                              afl_environment_variable_len)) {
+
+            afl->afl_env.afl_statsd_host =
+                (u8 *)get_afl_env(afl_environment_variables[i]);
+          } else if (!strncmp(env, "AFL_STATSD_PORT",
+
+                              afl_environment_variable_len)) {
+
+            afl->afl_env.afl_statsd_port =
+                (u8 *)get_afl_env(afl_environment_variables[i]);
+
           }
 
         } else {
diff --git a/src/afl-fuzz-statsd.c b/src/afl-fuzz-statsd.c
index e94f090c..7ae2efca 100644
--- a/src/afl-fuzz-statsd.c
+++ b/src/afl-fuzz-statsd.c
@@ -60,10 +60,8 @@ int statsd_send_metric(afl_state_t *afl) {
   u16   port = STATSD_DEFAULT_PORT;
   char *host = STATSD_DEFAULT_HOST;
 
-  char *port_env;
-  char *host_env;
-  if ((port_env = getenv("AFL_STATSD_PORT")) != NULL) { port = atoi(port_env); }
-  if ((host_env = getenv("AFL_STATSD_HOST")) != NULL) { host = host_env; }
+  if (afl->afl_env.afl_statsd_port) { port = atoi(afl->afl_env.afl_statsd_port); }
+  if (afl->afl_env.afl_statsd_host) { host = afl->afl_env.afl_statsd_host; }
 
   /* statds_sock is a global variable. We set it once in the beginning and reuse
   the socket. If the sendto later fail, we reset it to 0 to be able to recreate