From owner-freebsd-hackers Fri Jul 16 5:53: 3 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from smtp13.bellglobal.com (smtp13.bellglobal.com [204.101.251.52]) by hub.freebsd.org (Postfix) with ESMTP id 4AA6E156A0 for ; Fri, 16 Jul 1999 05:52:55 -0700 (PDT) (envelope-from hoek@FreeBSD.org) Received: from localhost.nowhere (Hamilton-ppp44850.sympatico.ca [206.172.76.43]) by smtp13.bellglobal.com (8.8.5/8.8.5) with ESMTP id IAA05598; Fri, 16 Jul 1999 08:54:22 -0400 (EDT) Received: (from tim@localhost) by localhost.nowhere (8.9.3/8.9.1) id DAA55974; Fri, 16 Jul 1999 03:30:18 -0400 (EDT) (envelope-from tim) Date: Fri, 16 Jul 1999 03:30:18 -0400 From: Tim Vanderhoek To: Warner Losh Cc: Sheldon Hearn , freebsd-hackers@FreeBSD.org Subject: Re: OpenBSD's strlcpy(3) and strlcat(3) Message-ID: <19990716033018.C54146@mad> References: <19990715194203.A54146@mad> <19990715183442.A53661@mad> <80092.932079193@axl.noc.iafrica.com> <19990715194203.A54146@mad> <199907160028.SAA01218@harmony.village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95i In-Reply-To: <199907160028.SAA01218@harmony.village.org>; from Warner Losh on Thu, Jul 15, 1999 at 06:28:52PM -0600 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Jul 15, 1999 at 06:28:52PM -0600, Warner Losh wrote: > > : Looking at OpenBSD's actual definition of strlcat() which returns the > : number of chars that would have been in the final string is > : potentially non-useful, but not really toooooo terrible. > > No. It is useful. If you look at the return value, you can detect > that an overflow would have happened and bail w/o having the overflow No, they could simply return sizeof(buf) + 1 and have the same effect. Running through the whole length of the string that would have been created is potentially non-useful [sic]. It also potentially slows strlcat() down, particularly is some programmers start to rely on its behaviour to find the new amount of memory needed to allocate instead of doing the math themselves. -- This is my .signature which gets appended to the end of my messages. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message