Add strndup

Matthew Dillon dillon at apollo.backplane.com
Tue Jun 20 23:31:01 PDT 2006


:andy wrote @ 20 Jun 2006 21:44:17 +0200:
:
:Fixed the off-by-one:
:http://ftp.fortunaty.net/DragonFly/inofficial/patches/strndup.patch

    Umm.  That code is broken.  len is only the maximum allowed length,
    the actual string may be smaller.

    so e.g. someone might do:  strndup("fubar", 16384).  The returned
    string should only be 'fubar\0', and only 6 bytes should be allocated,
    not 16384.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Submit mailing list