Date: Thu, 31 May 2001 20:13:26 +0100 From: David Malone <dwmalone@maths.tcd.ie> To: Kris Kennaway <kris@obsecurity.org> Cc: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>, 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: <20010531201326.A68855@walton.maths.tcd.ie> In-Reply-To: <20010531115418.B96927@xor.obsecurity.org>; from kris@obsecurity.org on Thu, May 31, 2001 at 11:54:18AM -0700 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
On Thu, May 31, 2001 at 11:54:18AM -0700, Kris Kennaway wrote:
> On Thu, May 31, 2001 at 11:37:31AM -0400, Garrett Wollman wrote:
> > <<On Wed, 30 May 2001 18:28:22 -0700, 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.
AFAIK: strn{cpy,cat} are designed for working on strings which are
stored in fixed sized storage (such as those in struct utmp). These
are not the same as "normal" C strings as they are only nul terminated
if the string is smaller than the storage space. Using strn{cpy,cat}
on normal C strings is just too fiddley to get right all the time.
In most cases the functions that do what people want are snprintf
(which is in C99) or the strl{cpy,cat} (which atleast *BSD have?).
I dunno what Posix or SUSv? say about these functions.
David.
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?20010531201326.A68855>
