diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libc/string/wcslcpy.3 | 160 |
1 files changed, 0 insertions, 160 deletions
diff --git a/src/lib/libc/string/wcslcpy.3 b/src/lib/libc/string/wcslcpy.3 deleted file mode 100644 index d279038079..0000000000 --- a/src/lib/libc/string/wcslcpy.3 +++ /dev/null | |||
@@ -1,160 +0,0 @@ | |||
1 | .\" $OpenBSD: wcslcpy.3,v 1.8 2024/08/07 04:59:45 guenther Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1998, 2000 Todd C. Miller <millert@openbsd.org> | ||
4 | .\" | ||
5 | .\" Permission to use, copy, modify, and distribute this software for any | ||
6 | .\" purpose with or without fee is hereby granted, provided that the above | ||
7 | .\" copyright notice and this permission notice appear in all copies. | ||
8 | .\" | ||
9 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | .\" | ||
17 | .Dd $Mdocdate: August 7 2024 $ | ||
18 | .Dt WCSLCPY 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm wcslcpy , | ||
22 | .Nm wcslcat | ||
23 | .Nd size-bounded wide string copying and concatenation | ||
24 | .Sh SYNOPSIS | ||
25 | .In wchar.h | ||
26 | .Ft size_t | ||
27 | .Fn wcslcpy "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t size" | ||
28 | .Ft size_t | ||
29 | .Fn wcslcat "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t size" | ||
30 | .Sh DESCRIPTION | ||
31 | The | ||
32 | .Fn wcslcpy | ||
33 | and | ||
34 | .Fn wcslcat | ||
35 | functions copy and concatenate wide strings respectively. | ||
36 | They are designed to be safer, more consistent, and less error prone | ||
37 | replacements for | ||
38 | .Xr wcsncpy 3 | ||
39 | and | ||
40 | .Xr wcsncat 3 . | ||
41 | Unlike those functions, | ||
42 | .Fn wcslcpy | ||
43 | and | ||
44 | .Fn wcslcat | ||
45 | take the full size of the buffer (not just the length) and guarantee to | ||
46 | terminate the result with a null wide character (as long as | ||
47 | .Fa size | ||
48 | is larger than 0 or, in the case of | ||
49 | .Fn wcslcat , | ||
50 | as long as there is at least one wide character free in | ||
51 | .Fa dst ) . | ||
52 | Note that a wide character for the null wide character should be included in | ||
53 | .Fa size . | ||
54 | Also note that | ||
55 | .Fn wcslcpy | ||
56 | and | ||
57 | .Fn wcslcat | ||
58 | only operate on wide strings that are terminated with a null wide character | ||
59 | (L'\e0'). | ||
60 | This means that for | ||
61 | .Fn wcslcpy | ||
62 | .Fa src | ||
63 | must be terminated with a null wide character and for | ||
64 | .Fn wcslcat | ||
65 | both | ||
66 | .Fa src | ||
67 | and | ||
68 | .Fa dst | ||
69 | must be terminated with a null wide character. | ||
70 | .Pp | ||
71 | The | ||
72 | .Fn wcslcpy | ||
73 | function copies up to | ||
74 | .Fa size | ||
75 | \(mi 1 wide characters from the wide string | ||
76 | .Fa src | ||
77 | to | ||
78 | .Fa dst , | ||
79 | terminating the result with a null wide character. | ||
80 | .Pp | ||
81 | The | ||
82 | .Fn wcslcat | ||
83 | function appends the wide string | ||
84 | .Fa src | ||
85 | to the end of | ||
86 | .Fa dst . | ||
87 | It will append at most | ||
88 | .Fa size | ||
89 | \(mi wcslen(dst) \(mi 1 wide characters, terminating the result with a null | ||
90 | wide character. | ||
91 | .Pp | ||
92 | If the | ||
93 | .Fa src | ||
94 | and | ||
95 | .Fa dst | ||
96 | strings overlap, the behavior is undefined. | ||
97 | .Sh RETURN VALUES | ||
98 | The | ||
99 | .Fn wcslcpy | ||
100 | and | ||
101 | .Fn wcslcat | ||
102 | functions return the total length of the wide string they tried to create. | ||
103 | For | ||
104 | .Fn wcslcpy | ||
105 | that means the length of | ||
106 | .Fa src . | ||
107 | For | ||
108 | .Fn wcslcat | ||
109 | that means the initial length of | ||
110 | .Fa dst | ||
111 | plus | ||
112 | the length of | ||
113 | .Fa src . | ||
114 | While this may seem somewhat confusing, it was done to make | ||
115 | truncation detection simple. | ||
116 | .Pp | ||
117 | Note, however, that if | ||
118 | .Fn wcslcat | ||
119 | traverses | ||
120 | .Fa size | ||
121 | wide characters without finding a null wide character, the length of the | ||
122 | string is considered to be | ||
123 | .Fa size | ||
124 | and the destination wide string will not be terminated with a null wide | ||
125 | character (since there was no space for it). | ||
126 | This keeps | ||
127 | .Fn wcslcat | ||
128 | from running off the end of a wide string. | ||
129 | In practice this should not happen (as it means that either | ||
130 | .Fa size | ||
131 | is incorrect or that | ||
132 | .Fa dst | ||
133 | is not terminated with a null wide character). | ||
134 | The check exists to prevent potential security problems in incorrect code. | ||
135 | .Sh SEE ALSO | ||
136 | .Xr strlcpy 3 , | ||
137 | .Xr swprintf 3 , | ||
138 | .Xr wcsncat 3 , | ||
139 | .Xr wcsncpy 3 | ||
140 | .Sh STANDARDS | ||
141 | The | ||
142 | .Fn wcslcpy | ||
143 | and | ||
144 | .Fn wcslcat | ||
145 | functions conform to | ||
146 | .St -p1003.1-2024 . | ||
147 | .Sh HISTORY | ||
148 | The | ||
149 | .Fn wcslcpy | ||
150 | and | ||
151 | .Fn wcslcat | ||
152 | functions first appeared in | ||
153 | .Ox 3.8 . | ||
154 | .Sh AUTHORS | ||
155 | The | ||
156 | .Fn wcslcpy | ||
157 | and | ||
158 | .Fn wcslcat | ||
159 | functions are based on code by | ||
160 | .An Todd C. Miller Aq Mt millert@openbsd.org . | ||