>From 3a9fdda5680fed183f0b33a9412fb88e0cb8f6a8 Mon Sep 17 00:00:00 2001 From: Isaac Dunham Date: Tue, 30 Jun 2015 21:06:20 -0700 Subject: [PATCH] src/compat/*_chk.c: fix build, add __strcpy_chk() --- src/compat/longjmp_chk.c | 4 ++-- src/compat/posix_chk.c | 7 +------ src/compat/realpath_chk.c | 2 +- src/compat/string_chk.c | 6 ++++++ src/compat/ttyname_r_chk.c | 1 + src/compat/wchar_chk.c | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/compat/longjmp_chk.c b/src/compat/longjmp_chk.c index e814ecc..576a1b5 100644 --- a/src/compat/longjmp_chk.c +++ b/src/compat/longjmp_chk.c @@ -1,7 +1,7 @@ #include #include -_Noreturn void __longjmp_chk(sigjmp_buf buf, int ret) +_Noreturn void __longjmp_chk(jmp_buf buf, int ret) { - longjmp((jmp_buf)buf, ret); + longjmp(buf, ret); } diff --git a/src/compat/posix_chk.c b/src/compat/posix_chk.c index 7e39754..2b9a845 100644 --- a/src/compat/posix_chk.c +++ b/src/compat/posix_chk.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -93,12 +94,6 @@ long __fdelt_chk(long d) return d / (8 * sizeof(d)); } -int __ttyname_r_chk(int fd, char *name, size_t size, size_t namelen) -{ - if (size > namelen) a_crash(); - return ttyname_r(fd, name, size); -} - char *__stpcpy_chk(char *d, const char *s, size_t dlen) { size_t slen = strnlen(s, dlen) + 1; diff --git a/src/compat/realpath_chk.c b/src/compat/realpath_chk.c index cc0089e..c2ac9f8 100644 --- a/src/compat/realpath_chk.c +++ b/src/compat/realpath_chk.c @@ -1,6 +1,6 @@ #include #include -#include "atomics.h" +#include "atomic.h" char *__realpath_chk(const char *filename, char *resolved, size_t resolved_len) { diff --git a/src/compat/string_chk.c b/src/compat/string_chk.c index ba77c9c..8a17c48 100644 --- a/src/compat/string_chk.c +++ b/src/compat/string_chk.c @@ -40,6 +40,12 @@ char *__strncat_chk(char *restrict dest, const char *restrict src, size_t n, siz return strncat(dest, src, n); } +char *__strcpy_chk(char *restrict dest, const char *restrict src, size_t destlen) +{ + if ( strlen(src) >= destlen) a_crash(); + return strcpy(dest, src); +} + char *__strncpy_chk(char *restrict dest, const char *restrict src, size_t n, size_t destlen) { if (n > destlen) a_crash(); diff --git a/src/compat/ttyname_r_chk.c b/src/compat/ttyname_r_chk.c index 50e70e5..cbede51 100644 --- a/src/compat/ttyname_r_chk.c +++ b/src/compat/ttyname_r_chk.c @@ -1,4 +1,5 @@ #include +#include "atomic.h" int __ttyname_r_chk(int fd, char *name, size_t size, size_t namelen) { diff --git a/src/compat/wchar_chk.c b/src/compat/wchar_chk.c index 66e35b1..fd5b075 100644 --- a/src/compat/wchar_chk.c +++ b/src/compat/wchar_chk.c @@ -5,7 +5,7 @@ size_t __mbsnrtowcs_chk(wchar_t *restrict wcs, const char **restrict src, size_t n, size_t wn, mbstate_t *restrict st, size_t wcslen) { if (wn > wcslen) a_crash(); - return msbnrtowcs(wcs, src, n, wn, st); + return mbsnrtowcs(wcs, src, n, wn, st); } size_t __mbsrtowcs_chk(wchar_t *restrict ws, const char **restrict src, size_t wn, mbstate_t *restrict st, size_t wslen) -- 2.4.5