Article View: comp.std.c
Article #1584strncat is insufficient
From: Rahul Dhesi
Date: Sun, 12 Aug 1990 01:30
Date: Sun, 12 Aug 1990 01:30
17 lines
995 bytes
995 bytes
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@oliveb.ATC.olivetti.com>
UUCP: oliveb!cirrusl!dhesi
Technical Details
Message-ID:
<2201@cirrusl.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!olivea!tymix!cirrusl!sunstorm!dhesiShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!olivea!tymix!cirrusl!sunstorm!dhesi From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Newsgroups: comp.std.c Subject: strncat is insufficient Message-ID: <2201@cirrusl.UUCP> Date: 12 Aug 90 01:30:06 GMT Sender: news@cirrusl.UUCP Organization: Cirrus Logic Inc. Lines: 17