strncat is insufficient
Rahul Dhesi
dhesi%cirrusl at oliveb.ATC.olivetti.com
Sun Aug 12 11:30:06 AEST 1990
Having recently written some code that does string manipulation and
takes some pains to avoid buffer overflow, I conclude that strncat() is
nearly useless. Most of the time I want to avoid string overflow by
doing this:
append str2 to str1, but cause at most n characters to be in str1.
Here is what strncat() does:
append str2 to str1, but copy at most n characters.
I think the standard C library badly needs another function called,
say, strlimcat(), which limits the length of the destination string to
some value.
--
Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
UUCP: oliveb!cirrusl!dhesi
More information about the Comp.std.c
mailing list