From edb2ded3af887cd0a206c0f00e20118d58a7775c Mon Sep 17 00:00:00 2001 From: sin Date: Wed, 15 Jul 2015 17:02:27 +0100 Subject: Fix stpncpy() check Do not crash unless the overflow would happen. --- include/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/string.h') diff --git a/include/string.h b/include/string.h index a4072d6..82f9f38 100644 --- 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); } -- cgit v1.3