[Bug c/96916] warning: ‘strndup’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 3 13:39:18 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96916

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
For strndup POSIX mentions the following application usage:

Implementations are free to malloc() a buffer containing either (size + 1)
bytes or (strnlen(s, size) + 1) bytes. Applications should not assume that
strndup() will allocate ( size + 1) bytes when strlen(s) is smaller than size.


More information about the Gcc-bugs mailing list