Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | --- strcpy.3.orig 2008-02-29 10:45:51.000000000 -0800 +++ strcpy.3 2008-02-29 12:08:34.000000000 -0800 @@ -40,18 +40,30 @@ .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 stpcpy "char *dst" "const char *src" +.Fo stpcpy +.Fa "char *s1" +.Fa "const char *s2" +.Fc .Ft char * -.Fn strcpy "char * restrict dst" "const char * restrict src" +.Fo strcpy +.Fa "char *restrict s1" +.Fa "const char *restrict s2" +.Fc .Ft char * -.Fn strncpy "char * restrict dst" "const char * restrict src" "size_t len" +.Fo strncpy +.Fa "char *restrict s1" +.Fa "const char *restrict s2" +.Fa "size_t n" +.Fc .Sh DESCRIPTION The .Fn stpcpy @@ -59,36 +71,39 @@ .Fn strcpy functions copy the string -.Fa src +.Fa s2 to -.Fa dst +.Fa s1 (including the terminating .Ql \e0 -character.) +character). .Pp The .Fn strncpy function copies at most -.Fa len +.Fa n characters from -.Fa src +.Fa s2 into -.Fa dst . +.Fa s1 . If -.Fa src +.Fa s2 is less than -.Fa len +.Fa n characters long, the remainder of -.Fa dst +.Fa s1 is filled with .Ql \e0 characters. Otherwise, -.Fa dst +.Fa s1 is .Em not terminated. +.Pp +The source and destination strings should not overlap, as the +behavior is undefined. .Sh RETURN VALUES The .Fn strcpy @@ -96,13 +111,13 @@ .Fn strncpy functions return -.Fa dst . +.Fa s1 . The .Fn stpcpy function returns a pointer to the terminating .Ql \e0 character of -.Fa dst . +.Fa s1 . .Sh EXAMPLES The following sets .Va chararray @@ -128,7 +143,7 @@ .Em not .Tn NUL terminate -.Va chararray +.Va chararray , because the length of the source string is greater than or equal to the length argument. .Pp @@ -159,7 +174,7 @@ .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. @@ -179,11 +194,6 @@ .Xr memcpy 3 , .Xr memmove 3 , .Xr strlcpy 3 -.Rs -.%T "The FreeBSD Security Architecture" -.Re -(See -.Pa "/usr/share/doc/{to be decided}" . ) .Sh STANDARDS The .Fn strcpy |