.\" SUCH DAMAGE.
.\"
.\" @(#)strcpy.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/string/strcpy.3,v 1.11 2001/10/01 16:09:00 ru Exp $
+.\" $FreeBSD: src/lib/libc/string/strcpy.3,v 1.24 2002/12/19 09:40:24 ru Exp $
.\"
.Dd August 9, 2001
.Dt STRCPY 3
.Os
.Sh NAME
-.Nm strcpy , strncpy
+.Nm stpcpy ,
+.Nm strcpy ,
+.Nm strncpy
.Nd copy strings
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In string.h
.Ft char *
-.Fn strcpy "char *dst" "const char *src"
+.Fo stpcpy
+.Fa "char *s1"
+.Fa "const char *s2"
+.Fc
.Ft char *
-.Fn strncpy "char *dst" "const char *src" "size_t len"
+.Fo strcpy
+.Fa "char *restrict s1"
+.Fa "const char *restrict s2"
+.Fc
+.Ft char *
+.Fo strncpy
+.Fa "char *restrict s1"
+.Fa "const char *restrict s2"
+.Fa "size_t n"
+.Fc
.Sh DESCRIPTION
The
+.Fn stpcpy
+and
.Fn strcpy
-function
-copies the string
-.Fa src
+functions
+copy the string
+.Fa s2
to
-.Fa dst
+.Fa s1
(including the terminating
.Ql \e0
character).
.Pp
The
.Fn strncpy
-function copies not more than
-.Fa len
+function copies at most
+.Fa n
characters from
-.Fa src
+.Fa s2
into
-.Fa dst ,
-appending
-.Ql \e0
-characters if
-.Fa src
+.Fa s1 .
+If
+.Fa s2
is less than
-.Fa len
-characters long, and
+.Fa n
+characters long,
+the remainder of
+.Fa s1
+is filled with
+.Ql \e0
+characters.
+Otherwise,
+.Fa s1
+is
.Em not
-terminating
-.Fa dst
-otherwise.
+terminated.
.Sh RETURN VALUES
The
.Fn strcpy
.Fn strncpy
functions
return
-.Fa dst .
+.Fa s1 .
+The
+.Fn stpcpy
+function returns a pointer to the terminating
+.Ql \e0
+character of
+.Fa s1 .
.Sh EXAMPLES
The following sets
.Va chararray
.Em not
.Tn NUL
terminate
-.Va chararray
+.Va chararray ,
because the length of the source string is greater than or equal
-to the length parameter.
+to the length argument.
.Pp
The following copies as many characters from
.Va input
.Pp
.Dl "(void)strlcpy(buf, input, sizeof(buf));"
.Pp
-Note that because
+Note that, because
.Xr strlcpy 3
is not defined in any standards, it should
only be used when portability is not a concern.
+.Sh SECURITY CONSIDERATIONS
+The
+.Fn strcpy
+function is easily misused in a manner which enables malicious users
+to arbitrarily change a running program's functionality through a
+buffer overflow attack.
+(See
+the FSA
+and
+.Sx EXAMPLES . )
.Sh SEE ALSO
.Xr bcopy 3 ,
.Xr memccpy 3 ,
functions
conform to
.St -isoC .
+The
+.Fn stpcpy
+function is an MS-DOS and GNUism.
+The
+.Fn stpcpy
+function
+conforms to no standard.
+.Sh HISTORY
+The
+.Fn stpcpy
+function first appeared in
+.Fx 4.4 ,
+coming from 1998-vintage Linux.