DALnet / bahamut

The Bahamut IRC Daemon
http://www.dal.net/?page=Bahamut
Other
59 stars 42 forks source link

-Wstrncat-size warnings #226

Open ryandesign opened 1 year ago

ryandesign commented 1 year ago

This warning appears when compiling with a modern Clang compiler:

send.c:1442:32: warning: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Wstrncat-size]
        strncat(nbuf, pattern, sizeof(nbuf) - strlen(nbuf));
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
send.c:1442:32: note: change the argument to be the free space in the destination buffer minus the terminating null byte
        strncat(nbuf, pattern, sizeof(nbuf) - strlen(nbuf));
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                               sizeof(nbuf) - strlen(nbuf) - 1