From 9333f82619499d74dfeb421ec789bf854cd8d071 Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Mon, 12 Oct 2020 22:36:50 +0100 Subject: Test checking that __strcat_chk is handled correctly with klee-libc --- test/Runtime/klee-libc/strcat_chk.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/Runtime/klee-libc/strcat_chk.c (limited to 'test/Runtime') 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 +#include +#include + +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)); +} -- cgit 1.4.1