about summary refs log tree commit diff
path: root/frida_mode/test/osx-lib/lib2.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-07-28 08:34:21 +0200
committerGitHub <noreply@github.com>2021-07-28 08:34:21 +0200
commit6d8813eb1a54a78f086e3f9b49642f67903218f3 (patch)
treed2b47c7aaff6e2d93bb1494cc0b4016f879b1044 /frida_mode/test/osx-lib/lib2.c
parent2a51358b1554ccb05d312487eec7d9deee53aaee (diff)
parentd7caf1b0f2bba283de36f546efb658d29ad488e1 (diff)
downloadafl++-6d8813eb1a54a78f086e3f9b49642f67903218f3.tar.gz
Merge pull request #1046 from WorksButNotTested/osx-lib
Changes to add additional FASAN configurations to osx-lib
Diffstat (limited to 'frida_mode/test/osx-lib/lib2.c')
-rw-r--r--frida_mode/test/osx-lib/lib2.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/frida_mode/test/osx-lib/lib2.c b/frida_mode/test/osx-lib/lib2.c
new file mode 100644
index 00000000..ba207210
--- /dev/null
+++ b/frida_mode/test/osx-lib/lib2.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+
+void __attribute__((noinline)) crashme(const uint8_t *Data, size_t Size) {
+
+  if (Size < 1) return;
+
+  char *buf = malloc(10);
+
+  if (buf == NULL) return;
+
+  switch (Data[0]) {
+
+    /* Underflow */
+    case 'U':
+      printf("Underflow\n");
+      buf[-1] = '\0';
+      free(buf);
+      break;
+    /* Overflow */
+    case 'O':
+      printf("Overflow\n");
+      buf[10] = '\0';
+      free(buf);
+      break;
+    /* Double free */
+    case 'D':
+      printf("Double free\n");
+      free(buf);
+      free(buf);
+      break;
+    /* Use after free */
+    case 'A':
+      printf("Use after free\n");
+      free(buf);
+      buf[0] = '\0';
+      break;
+    /* Test Limits (OK) */
+    case 'T':
+      printf("Test-Limits - No Error\n");
+      buf[0] = 'A';
+      buf[9] = 'I';
+      free(buf);
+      break;
+    case 'M':
+      printf("Memset too many\n");
+      memset(buf, '\0', 11);
+      free(buf);
+      break;
+    default:
+      printf("Nop - No Error\n");
+      break;
+
+  }
+
+
+}
+