Fix stpncpy() check

Do not crash unless the overflow would happen.
This commit is contained in:
sin 2015-07-15 17:02:27 +01:00
parent a51406af12
commit edb2ded3af

View File

@ -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);
}