diff options
Diffstat (limited to 'newlib/libc/ssp/mempcpy_chk.c')
-rw-r--r-- | newlib/libc/ssp/mempcpy_chk.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/newlib/libc/ssp/mempcpy_chk.c b/newlib/libc/ssp/mempcpy_chk.c new file mode 100644 index 0000000..fc2ccf8 --- /dev/null +++ b/newlib/libc/ssp/mempcpy_chk.c @@ -0,0 +1,21 @@ +#define _GNU_SOURCE +#include <sys/cdefs.h> +#include <ssp/ssp.h> +#include <string.h> + +#undef mempcpy + +void *__mempcpy_chk(void * __restrict, const void * __restrict, size_t, size_t); + +void * +__mempcpy_chk(void * __restrict dst, const void * __restrict src, size_t len, + size_t slen) +{ + if (len > slen) + __chk_fail(); + + if (__ssp_overlap((const char *)src, (const char *)dst, len)) + __chk_fail(); + + return mempcpy(dst, src, len); +} |