fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers.git
Log | Files | Refs | README | LICENSE

commit edb2ded3af887cd0a206c0f00e20118d58a7775c
parent a51406af124e712bc943b29c73fdf219e003ffaa
Author: sin <sin@2f30.org>
Date:   Wed Jul 15 17:02:27 +0100

Fix stpncpy() check

Do not crash unless the overflow would happen.

Diffstat:
include/string.h | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/string.h b/include/string.h @@ -88,7 +88,7 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n) { size_t __b = __builtin_object_size(__d, 0); - if (__n > __b) + if (__n > __b && strlen(__s) + 1 > __b) __builtin_trap(); return __orig_stpncpy(__d, __s, __n); }