Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 May 2001 15:45:27 -0400
From:      Garance A Drosihn <drosih@rpi.edu>
To:        Kris Kennaway <kris@obsecurity.org>, Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc:        Kris Kennaway <kris@obsecurity.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/lib/libc/gen setproctitle.3 syslog.3 src/lib/libc/stdio printf.3
Message-ID:  <p05100e03b73c4dc6a83c@[128.113.24.47]>
In-Reply-To: <20010531115418.B96927@xor.obsecurity.org>
References:  <200105252042.f4PKgfu84635@freefall.freebsd.org> <20010526004601.2109A3E2F@bazooka.unixfreak.org> <20010530172131.A60056@FreeBSD.org> <20010530182822.A79068@xor.obsecurity.org> <200105311537.LAA23815@khavrinen.lcs.mit.edu> <20010531115418.B96927@xor.obsecurity.org>

next in thread | previous in thread | raw e-mail | index | archive | help
At 11:54 AM -0700 5/31/01, Kris Kennaway wrote:
>On Thu, May 31, 2001 at 11:37:31AM -0400, Garrett Wollman wrote:
>  > <<On Wed, 30 May 2001, Kris Kennaway <kris@obsecurity.org> said:
>  >
>>  > things like how to use strncpy() properly
>>
>  > Mostly, ``don't.''  In almost every case where you think you
>  > might want to use strncpy(), strncat() is -- despite its
>  > name -- the correct function to use.
>
>Not Helpful.
>
>People use the function and will do so forever, so we should
>explain how to use it correctly.

Yes, it is helpful.  Any system which has strncpy will also
have strncat.  It IS true that strncpy is pretty much never
doing what people THINK it is doing.  It IS helpful to point
that out to people.  Point it out explicitly.  They can still
use it, for the 1% of cases where what it does is what they do
in fact want to happen.

However, for most situations the HELPFUL AND CORRECT advice
is to recommend that people to use one of strncat or
strlcpy/strlcat.  Garrett said:
      Mostly, ``don't.''
And any attempt to write helpful advice should MOSTLY say
that "this isn't really the routine you're looking for".

-- 
Garance Alistair Drosehn            =   gad@eclipse.acs.rpi.edu
Senior Systems Programmer           or  gad@freebsd.org
Rensselaer Polytechnic Institute    or  drosih@rpi.edu

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p05100e03b73c4dc6a83c>