about summary refs log tree commit diff
path: root/utils/argv_fuzzing/argv-fuzz-inl.h
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2022-12-20 14:31:09 +0100
committerGitHub <noreply@github.com>2022-12-20 14:31:09 +0100
commit60dc37a8cf09f8e9048e4b6a2204d6c90b27655a (patch)
treeab66c723be9ccadde42329cc85de1c141f8bddcd /utils/argv_fuzzing/argv-fuzz-inl.h
parent8cdc48f73a17ddd557897f2098937a8ba3bfe184 (diff)
parent0165ca8c6c485e36fe8e5fc6182ebeba2100932b (diff)
downloadafl++-60dc37a8cf09f8e9048e4b6a2204d6c90b27655a.tar.gz
Merge pull request #1592 from AFLplusplus/dev
Dev
Diffstat (limited to 'utils/argv_fuzzing/argv-fuzz-inl.h')
-rw-r--r--utils/argv_fuzzing/argv-fuzz-inl.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/utils/argv_fuzzing/argv-fuzz-inl.h b/utils/argv_fuzzing/argv-fuzz-inl.h
index c15c0271..ec22c53b 100644
--- a/utils/argv_fuzzing/argv-fuzz-inl.h
+++ b/utils/argv_fuzzing/argv-fuzz-inl.h
@@ -34,6 +34,7 @@
 #ifndef _HAVE_ARGV_FUZZ_INL
 #define _HAVE_ARGV_FUZZ_INL
 
+#include <stdlib.h>
 #include <unistd.h>
 
 #define AFL_INIT_ARGV()          \
@@ -63,7 +64,10 @@ static char **afl_init_argv(int *argc) {
   char *ptr = in_buf;
   int   rc = 0;
 
-  if (read(0, in_buf, MAX_CMDLINE_LEN - 2) < 0) {}
+  ssize_t num = read(0, in_buf, MAX_CMDLINE_LEN - 2);
+  if (num < 1) { _exit(1); }
+  in_buf[num] = '\0';
+  in_buf[num + 1] = '\0';
 
   while (*ptr && rc < MAX_CMDLINE_PAR) {