[PATCH] strlcat & strlcpy

Mark Bradshaw bradshaw@staff.crosswalk.com
Fri May 10 15:29:00 GMT 2002


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

===================

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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygwin.diff
Type: application/octet-stream
Size: 1001 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20020510/ea272892/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newlib.diff
Type: application/octet-stream
Size: 7064 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20020510/ea272892/attachment-0001.obj>


More information about the Cygwin-patches mailing list