diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-10-12 21:57:03 +0100 |
---|---|---|
committer | MartinNowack <2443641+MartinNowack@users.noreply.github.com> | 2020-11-09 19:39:13 +0000 |
commit | 08b8cb021d0fcda5607eac61a70fcf4fe0b5b098 (patch) | |
tree | 7213a418e8ea6024173658317d6737cd911397f0 /test/Runtime | |
parent | a4250b231c8527c669c0395db69bd83cf71e9065 (diff) | |
download | klee-08b8cb021d0fcda5607eac61a70fcf4fe0b5b098.tar.gz |
Test checking that __memchk_chk is handled correctly with the freestanding library.
Diffstat (limited to 'test/Runtime')
-rw-r--r-- | test/Runtime/FreeStanding/memcpy_chk.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Runtime/FreeStanding/memcpy_chk.c b/test/Runtime/FreeStanding/memcpy_chk.c new file mode 100644 index 00000000..d1905608 --- /dev/null +++ b/test/Runtime/FreeStanding/memcpy_chk.c @@ -0,0 +1,28 @@ +// This test checks that __memcpy_chk is properly handled + +// 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 --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 --exit-on-error %t3.bc + +#include "klee/klee.h" + +#include <assert.h> +#include <stdlib.h> +#include <string.h> + +int main() { +#define N 4 + char *s = malloc(N); + klee_make_symbolic(s, N, "s"); + s[N - 1] = '\0'; + char *d = malloc(N); + memcpy(d, s, N); + + int i; + for (i = 0; i < N; i++) + assert(s[i] == d[i]); +} |