[PATCH] strlcat & strlcpy

Thomas Fitzsimmons fitzsim@redhat.com
Mon May 13 12:36:00 GMT 2002

On Fri, 2002-05-10 at 18:28, Mark Bradshaw wrote:
> Here's a patch to cygwin and newlib that adds the functions strlcat and
> strlcpy.  These functions are replacement functions for strncat and strncpy.
> They were created by the OpenBSD team to address buffer overflow problems
> that can happen so easily when using the "n" versions.  Some other OS's have
> picked them up already, and software packages have begun to use them when
> available.  Aside from security benefits there are also performance
> benefits.  Strlcat is much faster than strncat, due to strncat's penchant
> for padding the destination string.
> The original source for these two come from OpenBSD.  You can find them
> here:
> http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/
> A good discussion of the new functions can be found here:
> http://www.courtesan.com/todd/papers/strlcpy.html

I've applied this, with one change.  I moved the string.h declarations
to the !__STRICT_ANSI__ section of that file.

Do you have any tests for these functions that you would like to
contribute to our new testsuite?


> ===================
> For newlib:
> 2002-05-10  Mark Bradshaw  <bradshaw@staff.crosswalk.com>
>         * libc/include/string.h: Add strlcat and strlcpy.
>         * libc/string/Makefile.am: Add strlcat.c and strlcpy.c.
>         * libc/string/strlcat.c: New file.
>         * libc/string/strlcpy.c: New file.
> For cygwin:
> 2002-05-10  Mark Bradshaw  <bradshaw@staff.crosswalk.com>
> 	  * cygwin.din: Add strlcat and strlcpy.
> 	  * include/cygwin/version.h: Increment API minor version number.
Thomas Fitzsimmons
Red Hat Canada Limited        e-mail: fitzsim@redhat.com
2323 Yonge Street, Suite 300
Toronto, ON M4P2C9

More information about the Newlib mailing list