about summary refs log tree commit diff
path: root/test-instr.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-03-09 11:39:12 +0100
committervan Hauser <vh@thc.org>2020-03-09 11:39:12 +0100
commit581097d58d6f8de05e05eec74344053bd74c3145 (patch)
treef8d81a4c729a41dbbfe9f06794f57333bae6d6e9 /test-instr.c
parentdba3595c0ae26795a78753ea33ff0c3edf9d6328 (diff)
downloadafl++-581097d58d6f8de05e05eec74344053bd74c3145.tar.gz
expanded test-instr to also work with input files via "-f @@" and changed the test.sh values
Diffstat (limited to 'test-instr.c')
-rw-r--r--test-instr.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/test-instr.c b/test-instr.c
index ddfd3695..f96db868 100644
--- a/test-instr.c
+++ b/test-instr.c
@@ -18,22 +18,39 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
 int main(int argc, char** argv) {
 
+  int   fd = 0;
   char  buff[8];
   char* buf = buff;
 
   // we support command line parameter and stdin
-  if (argc > 1) {
+  if (argc == 2) {
 
     buf = argv[1];
     printf("Input %s - ", buf);
 
-  } else if (read(0, buf, sizeof(buf)) < 1) {
+  } else {
 
-    printf("Hum?\n");
-    return 1;
+    if (argc >= 3 && strcmp(argv[1], "-f") == 0)
+      if ((fd = open(argv[2], O_RDONLY)) < 0) {
+
+        fprintf(stderr, "Error: unable to open %s\n", argv[2]);
+        exit(-1);
+
+      }
+
+    if (read(fd, buf, sizeof(buf)) < 1) {
+
+      printf("Hum?\n");
+      return 1;
+
+    }
 
   }