summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorQuentin Rameau2024-10-02 21:15:12 +0200
committerjvoisin2024-10-04 00:16:50 +0200
commit6573631a5e4339a2fc2f86680e36e35e25bf416c (patch)
treeb2a9e8938b69d821a1e3bd30ddee5a5c3214728c /include
parent60202fb5b50f3e56bf82f3424360377a29e25709 (diff)
Fix usage of strnlen
As with previous commit, some strnlen calls where introduced in 22a8094, but not reverted. As strnlen isn't part of C standard, this was breaking C builds.
Diffstat (limited to 'include')
-rw-r--r--include/string.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/string.h b/include/string.h
index c1c24bc..9df99fc 100644
--- a/include/string.h
+++ b/include/string.h
@@ -296,7 +296,9 @@ _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
296 __fh_size_t __b = __fh_bos(__d, 0); 296 __fh_size_t __b = __fh_bos(__d, 0);
297 297
298 if (__n > __b) { 298 if (__n > __b) {
299 __fh_size_t __sl = strnlen(__s, __n); 299 __fh_size_t __sl = strlen(__s);
300 if (__sl > __n)
301 __sl = __n;
300 __fh_size_t __dl = strlen(__d); 302 __fh_size_t __dl = strlen(__d);
301 if (__sl + __dl + 1 > __b) 303 if (__sl + __dl + 1 > __b)
302 __builtin_trap(); 304 __builtin_trap();
@@ -316,7 +318,9 @@ _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d,
316#if __has_builtin(__builtin___strncpy_chk) && FORTIFY_USE_NATIVE_CHK 318#if __has_builtin(__builtin___strncpy_chk) && FORTIFY_USE_NATIVE_CHK
317 return __builtin___strncpy_chk(__d, __s, __n, __fh_bos(__d, 0)); 319 return __builtin___strncpy_chk(__d, __s, __n, __fh_bos(__d, 0));
318#else 320#else
319 __fh_size_t max_len_s = strnlen(__s, __n); 321 __fh_size_t max_len_s = strlen(__s);
322 if (max_len_s > __n)
323 max_len_s = __n;
320 if (__fh_overlap(__d, max_len_s, __s, max_len_s)) 324 if (__fh_overlap(__d, max_len_s, __s, max_len_s))
321 __builtin_trap(); 325 __builtin_trap();
322 326