Skip to content

Commit d72bf2f

Browse files
committed
Revert d259429
As reported on irc: ``` 17:51 <q> jvoisin, fortify-headers seems to be broken (on Alpine at least) 17:52 <q> Repeating the message from over-there: 17:52 <q> /usr/include/fortify/string.h: In function 'strncat': 17:52 <q> /usr/include/fortify/string.h:297:36: error: implicit declaration of function 'strnlen'; did you mean 'strlen'? [-Wimplicit-function-declaration] 17:52 <q> This is with a simple file that includes string.h and call strncat, built with c99 -O1 f.c ```
1 parent c4d9299 commit d72bf2f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/string.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s,
208208
#if __has_builtin(__builtin___stpncpy_chk) && FORTIFY_USE_NATIVE_CHK
209209
return __builtin___stpncpy_chk(__d, __s, __n, __fh_bos(__d, 0));
210210
#else
211-
__fh_size_t max_len_s = strnlen(__s, __n);
211+
__fh_size_t __max_len_s = strlen(__s);
212+
if (max_len_s > __n)
213+
max_len_s = __n;
212214
if (__fh_overlap(__d, max_len_s, __s, max_len_s))
213215
__builtin_trap();
214216

0 commit comments

Comments
 (0)