about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2020-10-12 22:36:50 +0100
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2020-11-09 19:39:13 +0000
commit9333f82619499d74dfeb421ec789bf854cd8d071 (patch)
tree7c483a7d29b2edfad3003d4d9d4f9f1fb661eb14
parentae5ed000ba0f0f232c210ada9e3ab2594f18c7c7 (diff)
downloadklee-9333f82619499d74dfeb421ec789bf854cd8d071.tar.gz
Test checking that __strcat_chk is handled correctly with klee-libc
-rw-r--r--test/Runtime/klee-libc/strcat_chk.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Runtime/klee-libc/strcat_chk.c b/test/Runtime/klee-libc/strcat_chk.c
new file mode 100644
index 00000000..58b806ce
--- /dev/null
+++ b/test/Runtime/klee-libc/strcat_chk.c
@@ -0,0 +1,32 @@
+// This test checks that __strcat_chk is properly handled when klee-libc is used
+
+// RUN: %clang %s -emit-llvm -O2 -g -c -D_FORTIFY_SOURCE=1 -o %t2.bc
+// RUN: rm -rf %t.klee-out
+// RUN: %klee --output-dir=%t.klee-out --libc=klee --exit-on-error %t2.bc
+
+// RUN: %clang %s -emit-llvm -O2 -g -c -D_FORTIFY_SOURCE=2 -o %t3.bc
+// RUN: rm -rf %t.klee-out
+// RUN: %klee --output-dir=%t.klee-out --libc=klee --exit-on-error %t3.bc
+
+#include "klee/klee.h"
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main() {
+#define N 7
+  int i;
+  char *s = malloc(N);
+  klee_make_symbolic(s, N, "s");
+  s[N - 1] = '\0';
+
+  char *d = malloc(N + 4);
+  d[0] = 'a';
+  d[1] = 'b';
+  d[2] = 'c';
+  d[3] = '\0';
+  strcat(d, s);
+
+  assert(!strcmp(s, d + 3));
+}