🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.2bsd
Article #180

Re: V1.21 (strncat is broken)

#180
From: Rob Warnock
Date: Fri, 08 Jan 1988 05:41
27 lines
1457 bytes
In article <4557@teddy.UUCP> you write:
+---------------
| >	strncat(3) doesn't truncate strings correctly.
| Please don't "fix" this "bug".  It is DOCUMENTED to work this way.  If
| the second string is longer than the size "n" supplied, then NO NULL
| TERMINATER is appended.  It is your MISUSE of "strncat" at fault here!
| I agree, it is a pain in the ass, but this is the way strncat has
| always worked since the beginning of C!
+---------------

Sorry, "jpn", Keith was right the first time. The posted fix was to "strncat",
NOT to "strncpy"! (Yeah, I had to look twice, myself...)

True, "strncpy(dest, src, n)" does (read "MUST") leave the string unterminated
if strlen(src) >= n, but "strncat(dest, src, n)" ALWAYS null-terminates (after
copying at most "n" bytes).

Better luck next time...   ;-}


Rob Warnock
Systems Architecture Consultant

UUCP:	  {amdcad,fortune,sun,attmail}!redwood!rpw3
ATTmail:  !rpw3
DDD:	  (415)572-2607
USPS:	  627 26th Ave, San Mateo, CA  94403
Technical Details
Message-ID: <19876@amdcad.AMD.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!nbires!hao!ames!amdcad!rpw3
References: <8801062002.AA15696@okeeffe.Berkeley.EDU> <4557@teddy.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!nbires!hao!ames!amdcad!rpw3
From: rpw3@amdcad.AMD.COM (Rob Warnock)
Newsgroups: comp.bugs.2bsd
Subject: Re: V1.21 (strncat is broken)
Message-ID: <19876@amdcad.AMD.COM>
Date: 8 Jan 88 05:41:43 GMT
References: <8801062002.AA15696@okeeffe.Berkeley.EDU> <4557@teddy.UUCP>
Reply-To: rpw3@amdcad.UUCP (Rob Warnock)
Organization: [Consultant] San Mateo, CA
Lines: 27
Summary: look again: "strncat", not "strncpy"