Date: Thu, 15 Jul 1999 18:05:06 -0600 From: Brett Glass <brett@lariat.org> To: Sheldon Hearn <sheldonh@uunet.co.za> Cc: Warner Losh <imp@village.org>, Paul Hart <hart@iserver.com>, freebsd-security@FreeBSD.ORG Subject: Re: OpenBSD's strlcpy(3) and strlcat(3) Message-ID: <4.2.0.58.19990715180119.04723d20@localhost> In-Reply-To: <80788.932082769@axl.noc.iafrica.com> References: <Your message of "Thu, 15 Jul 1999 17:47:03 CST." <4.2.0.58.19990715174241.045f0550@localhost>
next in thread | previous in thread | raw e-mail | index | archive | help
The danger here is that the semantics are changed so radically by the value of the argument. This is an invitation to confusion. A more consistent way to do it would be to have the function return zero if the programmer opted not to know about any shortfall. Or, even better, ALWAYS return the shortfall. The programmer can then discard the return value if he's really willing to ignore it (perhaps at his peril). --Brett At 01:52 AM 7/16/99 +0200, Sheldon Hearn wrote: >On Thu, 15 Jul 1999 17:47:03 CST, Brett Glass wrote: > > > How about returning the shortfall as the return value of the function? > >Um, hello? That's exactly what I'm proposing: > > > >RETURN VALUES > > > > > >If the optional shortfall argument is passed non-zero, the functions > > >return the number of characters from src that are missing in dst after > > >the operation. Otherwise, they return the length of dst. In either case, > > >the return value does not include the NUL terminator. > >:-) > >Ciao, >Sheldon. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-security" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4.2.0.58.19990715180119.04723d20>