From owner-cvs-all Thu May 31 12:13:36 2001 Delivered-To: cvs-all@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 0B76C37B422; Thu, 31 May 2001 12:13:30 -0700 (PDT) (envelope-from dwmalone@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 31 May 2001 20:13:29 +0100 (BST) Date: Thu, 31 May 2001 20:13:26 +0100 From: David Malone To: Kris Kennaway Cc: Garrett Wollman , 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> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010531115418.B96927@xor.obsecurity.org>; from kris@obsecurity.org on Thu, May 31, 2001 at 11:54:18AM -0700 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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: > > < 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