about summary refs log tree commit diff
path: root/unicorn_mode/samples/persistent
diff options
context:
space:
mode:
authorrichinseattle@gmail.com <richinseattle@gmail.com>2021-03-18 01:37:40 -0700
committerrichinseattle@gmail.com <richinseattle@gmail.com>2021-03-18 01:37:40 -0700
commitc397becd81229d71b55acf89a31710bead3707aa (patch)
tree8306b59e88e22d7090fd786690227dacc99e24e3 /unicorn_mode/samples/persistent
parent62508c3b446a893f0afead9a6d0546d53d588a13 (diff)
parent94312796f936ba1830b61432a0f958e192dd212f (diff)
downloadafl++-c397becd81229d71b55acf89a31710bead3707aa.tar.gz
Merge branch 'dev' of https://github.com/AFLplusplus/AFLplusplus into dev
Diffstat (limited to 'unicorn_mode/samples/persistent')
-rw-r--r--unicorn_mode/samples/persistent/simple_target_noncrashing.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/unicorn_mode/samples/persistent/simple_target_noncrashing.c b/unicorn_mode/samples/persistent/simple_target_noncrashing.c
index 00764473..9257643b 100644
--- a/unicorn_mode/samples/persistent/simple_target_noncrashing.c
+++ b/unicorn_mode/samples/persistent/simple_target_noncrashing.c
@@ -10,7 +10,7 @@
  * Written by Nathan Voss <njvoss99@gmail.com>
  * Adapted by Lukas Seidel <seidel.1@campus.tu-berlin.de>
  */
-
+#include <string.h>
 
 int main(int argc, char** argv) {
   if(argc < 2){
@@ -19,15 +19,19 @@ int main(int argc, char** argv) {
 
   char *data_buf = argv[1];
 
-  if len(data_buf < 20) {
-  if (data_buf[20] != 0) {
+  if (strlen(data_buf) >= 21 && data_buf[20] != 0) {
     printf("Not crashing");
-  } else if (data_buf[0] > 0x10 && data_buf[0] < 0x20 && data_buf[1] > data_buf[2]) {
+  } else if (strlen(data_buf) > 1
+             && data_buf[0] > 0x10 && data_buf[0] < 0x20 && data_buf[1] > data_buf[2]) {
     printf("Also not crashing with databuf[0] == %c", data_buf[0])
-  } else if (data_buf[9] == 0x00 && data_buf[10] != 0x00 && data_buf[11] == 0x00) {
+  }
+#if 0
+  // not possible with argv (zero terminated strings) (hexcoder-)
+  // do not try to access data_buf[10] and beyond
+  else if (data_buf[9] == 0x00 && data_buf[10] != 0x00 && data_buf[11] == 0x00) {
     // Cause a crash if data[10] is not zero, but [9] and [11] are zero
     unsigned char invalid_read = *(unsigned char *) 0x00000000;
   }
-
+#endif
   return 0;
 }