summaryrefslogtreecommitdiff
path: root/include/string.h
diff options
context:
space:
mode:
authorsin2015-07-15 17:02:27 +0100
committersin2015-07-15 17:02:27 +0100
commitedb2ded3af887cd0a206c0f00e20118d58a7775c (patch)
treedab7ea871f68ae37c93474eda572aab9304ea244 /include/string.h
parenta51406af124e712bc943b29c73fdf219e003ffaa (diff)
Fix stpncpy() check
Do not crash unless the overflow would happen.
Diffstat (limited to '')
-rw-r--r--include/string.h2
1 files changed, 1 insertions, 1 deletions
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)
88{ 88{
89 size_t __b = __builtin_object_size(__d, 0); 89 size_t __b = __builtin_object_size(__d, 0);
90 90
91 if (__n > __b) 91 if (__n > __b && strlen(__s) + 1 > __b)
92 __builtin_trap(); 92 __builtin_trap();
93 return __orig_stpncpy(__d, __s, __n); 93 return __orig_stpncpy(__d, __s, __n);
94} 94}