diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-10-14 14:56:52 +0100 |
---|---|---|
committer | MartinNowack <2443641+MartinNowack@users.noreply.github.com> | 2020-11-09 19:39:13 +0000 |
commit | dbeab5ee24c669578765783a1a8f00af7b2b52a5 (patch) | |
tree | 14c177d4cf09feafe2f8c9d8008cabdd1edcb7c0 /runtime/klee-libc/fortify-klibc.c | |
parent | 9333f82619499d74dfeb421ec789bf854cd8d071 (diff) | |
download | klee-dbeab5ee24c669578765783a1a8f00af7b2b52a5.tar.gz |
Added fortified versions for the functions in the klee-libc library
Diffstat (limited to 'runtime/klee-libc/fortify-klibc.c')
-rw-r--r-- | runtime/klee-libc/fortify-klibc.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/runtime/klee-libc/fortify-klibc.c b/runtime/klee-libc/fortify-klibc.c new file mode 100644 index 00000000..ed4a3033 --- /dev/null +++ b/runtime/klee-libc/fortify-klibc.c @@ -0,0 +1,37 @@ +//===-- fortify-klibc.c ---------------------------------------------------===// +// +// The KLEE Symbolic Virtual Machine +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +/* Fortified versions of the libc functions defined in the klee-libc library */ + +#include "klee/klee.h" + +#include <string.h> + +void *__mempcpy_chk(void *dest, const void *src, size_t len, size_t destlen) { + if (len > destlen) + klee_report_error(__FILE__, __LINE__, "mempcpy overflow", "ptr.err"); + + return mempcpy(dest, src, len); +} + +char *__stpcpy_chk(char *dest, const char *src, size_t destlen) { + return stpcpy(dest, src); +} + +char *__strcat_chk(char *dest, const char *src, size_t destlen) { + return strcat(dest, src); +} + +char *__strcpy_chk(char *dest, const char *src, size_t destlen) { + return strcpy(dest, src); +} + +char *__strncpy_chk(char *s1, const char *s2, size_t n, size_t s1len) { + return strncpy(s1, s2, n); +} |