commit d2594298b89d0fb8989cae3ebc8900e77b6aa478 parent d2ab22e80e192f6013f7fa83a6b28864bd5865e4 Author: jvoisin <julien.voisin@dustri.org> Date: Wed, 20 Sep 2023 17:00:11 +0200 Replace a strlen+condition with strnlen Diffstat:
M | include/string.h | | | 4 | +--- |
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/string.h b/include/string.h @@ -191,9 +191,7 @@ _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, size_t __b = __bos(__d, 0); if (__n > __b) { - size_t __sl = strlen(__s); - if (__sl > __n) - __sl = __n; + size_t __sl = strnlen(__s, __n); size_t __dl = strlen(__d); if (__sl + __dl + 1 > __b) __builtin_trap();