Date: Tue, 16 Jan 2001 18:07:51 -0500 From: Chris Faulhaber <jedgar@fxp.org> To: Warner Losh <imp@harmony.village.org> Cc: freebsd-audit@FreeBSD.ORG Subject: Re: strlcat fixes Message-ID: <20010116180751.A67654@peitho.fxp.org> In-Reply-To: <200101162305.f0GN51s32264@harmony.village.org>; from imp@harmony.village.org on Tue, Jan 16, 2001 at 04:05:01PM -0700 References: <20010116174845.A95772@peitho.fxp.org> <200101162305.f0GN51s32264@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jan 16, 2001 at 04:05:01PM -0700, Warner Losh wrote: > In message <20010116174845.A95772@peitho.fxp.org> Chris Faulhaber writes: > : The first ensures that memory is not read if strlcat is > : called with a 0 size, ensuring potentially unallocated > : memory is not read: > : > : - while (*d != '\0' && n-- != 0) > : + while (n-- != 0 && *d != '\0') > > This doesn't matter. The only time this would matter would be if dst > was NULL, which is undefined anyway. There's no reason to change this > and it makes us gratuitously different than OpenBSD. > Actually, OpenBSD merged the changes last week: CVSROOT: /cvs Module name: src Changes by: millert@cvs.openbsd.org 2001/01/12 15:55:24 Modified files: lib/libc/string: strlcat.c Log message: Reverse the order of two loop invariant to make 'strlcat(0, "foo", 0)' not get a SEGV; Richard Kettlewell <rjk@greenend.org.uk> > : The second corrects the wording regarding the return value: > : > : - * Returns strlen(src); if retval >= siz, truncation occurred. > : + * Returns the smaller of strlen(dst) + strlen(src) and siz + strlen(src); > : + * if retval >= siz, truncation occurred. > > This is OK. However, I'll talk to Todd Miller of OpenBSD tonight to > coordinate with them this change. I'm having a beer with him and he's > keeper of libc in OpenBSD. You might want to mail him before making > the change in our tree. > Ditto... -- Chris D. Faulhaber - jedgar@fxp.org - jedgar@FreeBSD.org -------------------------------------------------------- FreeBSD: The Power To Serve - http://www.FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010116180751.A67654>