fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

commit 114b563adc2b942bc5abd4c5820507076d453f64
parent c4d9299abf7f6b941493fc487d2ccbb47d756479
Author: jvoisin <julien.voisin@dustri.org>
Date:   Mon,  2 Sep 2024 16:08:38 +0200

Revert d2594298b89d0fb8989cae3ebc8900e77b6aa478

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
```

Diffstat:
Minclude/string.h | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/string.h b/include/string.h @@ -208,7 +208,9 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s, #if __has_builtin(__builtin___stpncpy_chk) && FORTIFY_USE_NATIVE_CHK return __builtin___stpncpy_chk(__d, __s, __n, __fh_bos(__d, 0)); #else - __fh_size_t max_len_s = strnlen(__s, __n); + __fh_size_t max_len_s = strlen(__s); + if (max_len_s > __n) + max_len_s = __n; if (__fh_overlap(__d, max_len_s, __s, max_len_s)) __builtin_trap();