https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83007
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Martin Sebor from comment #1) > A common mistake with strncat is to specify as the bound the source of the > source string (instead of the remaining space in the destination), as in: That doesn't really make sense to me. If you know the remaining space in the destination, that would mean also you know the length of the string in the destination; then you should just use the known location of the '\0' as the spot to memcpy + termination. target.c uses strncat for a completely different purpose, which better matches what the function does - sometimes it wants to copy the whole src string, but sometimes just a portion of it and that is what is specified by the third strncat argument.