strlcat/strlcpy vs overlapping arguments

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <misc@...>
Date: Tuesday, May 27, 2008 - 6:53 am

In message ,
"Ted Unangst" pointed out that
# strlcpy is wrong with overlapping arguments.

Should this be mentioned in the strlcpy/strlcat man page?
(It isn't as of 4.3-release.) Here's a suggested patch:

Index: strlcpy.3
===================================================================
RCS file: /cvs/src/lib/libc/string/strlcpy.3,v
retrieving revision 1.19
diff -u -r1.19 strlcpy.3
--- strlcpy.3 31 May 2007 19:19:32 -0000 1.19
+++ strlcpy.3 27 May 2008 10:51:45 -0000
@@ -88,6 +88,17 @@
It will append at most
.Fa size
- strlen(dst) - 1 bytes, NUL-terminating the result.
+.Pp
+.Fa src
+and
+.Fa dst
+must not overlap, i.e., no character copied by
+.Fn strlcpy
+or
+.Fn strlcat
+may be within the initial
+.Fa dst
+string.
.Sh RETURN VALUES
The
.Fn strlcpy

ciao,

--
-- Jonathan Thornburg (remove -animal to reply)
School of Mathematics, U of Southampton, England
"Washing one's hands of the conflict between the powerful and the
powerless means to side with the powerful, not to be neutral."
-- quote by Freire / poster by Oxfam

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
strlcat/strlcpy vs overlapping arguments, Jonathan Thornburg, (Tue May 27, 6:53 am)
Re: strlcat/strlcpy vs overlapping arguments, Ted Unangst, (Tue May 27, 12:41 pm)
Re: strlcat/strlcpy vs overlapping arguments , Theo de Raadt, (Tue May 27, 12:52 pm)
Re: strlcat/strlcpy vs overlapping arguments, Craig Findlay, (Tue May 27, 7:09 pm)
Re: strlcat/strlcpy vs overlapping arguments, Ted Unangst, (Tue May 27, 9:07 pm)
Re: strlcat/strlcpy vs overlapping arguments, Pollywog, (Tue May 27, 7:55 pm)
Re: strlcat/strlcpy vs overlapping arguments, Tony Abernethy, (Tue May 27, 7:43 pm)
Re: strlcat/strlcpy vs overlapping arguments, Glenn Becker, (Tue May 27, 8:18 pm)
Re: strlcat/strlcpy vs overlapping arguments, Tony Abernethy, (Tue May 27, 9:13 pm)
Re: strlcat/strlcpy vs overlapping arguments , Theo de Raadt, (Tue May 27, 7:16 pm)