diff options
Diffstat (limited to 'runtime/Freestanding/fortify-fs.c')
-rw-r--r-- | runtime/Freestanding/fortify-fs.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/runtime/Freestanding/fortify-fs.c b/runtime/Freestanding/fortify-fs.c new file mode 100644 index 00000000..3bbd34df --- /dev/null +++ b/runtime/Freestanding/fortify-fs.c @@ -0,0 +1,36 @@ +//===-- fortify-fs.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 FreeStanding library + */ + +#include "klee/klee.h" + +#include <string.h> + +void *__memmove_chk(void *dest, const void *src, size_t len, size_t destlen) { + if (len > destlen) + klee_report_error(__FILE__, __LINE__, "memmove overflow", "ptr.err"); + + return memmove(dest, src, len); +} + +void *__memset_chk(void *dest, int c, size_t len, size_t destlen) { + if (len > destlen) + klee_report_error(__FILE__, __LINE__, "memset overflow", "ptr.err"); + + return memset(dest, c, len); +} + +void *__memcpy_chk(void *dest, const void *src, size_t len, size_t destlen) { + if (len > destlen) + klee_report_error(__FILE__, __LINE__, "memcpy overflow", "ptr.err"); + + return memcpy(dest, src, len); +} |