1 | /* Checking macros for wchar functions. |
2 | Copyright (C) 2005-2021 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #ifndef _WCHAR_H |
20 | # error "Never include <bits/wchar2.h> directly; use <wchar.h> instead." |
21 | #endif |
22 | |
23 | |
24 | extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1, |
25 | const wchar_t *__restrict __s2, size_t __n, |
26 | size_t __ns1) __THROW; |
27 | extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias, |
28 | (wchar_t *__restrict __s1, |
29 | const wchar_t *__restrict __s2, size_t __n), |
30 | wmemcpy); |
31 | extern wchar_t *__REDIRECT_NTH (__wmemcpy_chk_warn, |
32 | (wchar_t *__restrict __s1, |
33 | const wchar_t *__restrict __s2, size_t __n, |
34 | size_t __ns1), __wmemcpy_chk) |
35 | __warnattr ("wmemcpy called with length bigger than size of destination " |
36 | "buffer" ); |
37 | |
38 | __fortify_function wchar_t * |
39 | __NTH (wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, |
40 | size_t __n)) |
41 | { |
42 | if (__glibc_objsize0 (__s1) != (size_t) -1) |
43 | { |
44 | if (!__builtin_constant_p (__n)) |
45 | return __wmemcpy_chk (__s1, __s2, __n, |
46 | __glibc_objsize0 (__s1) / sizeof (wchar_t)); |
47 | |
48 | if (__n > __glibc_objsize0 (__s1) / sizeof (wchar_t)) |
49 | return __wmemcpy_chk_warn (__s1, __s2, __n, |
50 | __glibc_objsize0 (__s1) / sizeof (wchar_t)); |
51 | } |
52 | return __wmemcpy_alias (__s1, __s2, __n); |
53 | } |
54 | |
55 | |
56 | extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2, |
57 | size_t __n, size_t __ns1) __THROW; |
58 | extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1, |
59 | const wchar_t *__s2, |
60 | size_t __n), wmemmove); |
61 | extern wchar_t *__REDIRECT_NTH (__wmemmove_chk_warn, |
62 | (wchar_t *__s1, const wchar_t *__s2, |
63 | size_t __n, size_t __ns1), __wmemmove_chk) |
64 | __warnattr ("wmemmove called with length bigger than size of destination " |
65 | "buffer" ); |
66 | |
67 | __fortify_function wchar_t * |
68 | __NTH (wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)) |
69 | { |
70 | if (__glibc_objsize0 (__s1) != (size_t) -1) |
71 | { |
72 | if (!__builtin_constant_p (__n)) |
73 | return __wmemmove_chk (__s1, __s2, __n, |
74 | __glibc_objsize0 (__s1) / sizeof (wchar_t)); |
75 | |
76 | if (__n > __glibc_objsize0 (__s1) / sizeof (wchar_t)) |
77 | return __wmemmove_chk_warn (__s1, __s2, __n, |
78 | (__glibc_objsize0 (__s1) |
79 | / sizeof (wchar_t))); |
80 | } |
81 | return __wmemmove_alias (__s1, __s2, __n); |
82 | } |
83 | |
84 | |
85 | #ifdef __USE_GNU |
86 | extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1, |
87 | const wchar_t *__restrict __s2, size_t __n, |
88 | size_t __ns1) __THROW; |
89 | extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias, |
90 | (wchar_t *__restrict __s1, |
91 | const wchar_t *__restrict __s2, |
92 | size_t __n), wmempcpy); |
93 | extern wchar_t *__REDIRECT_NTH (__wmempcpy_chk_warn, |
94 | (wchar_t *__restrict __s1, |
95 | const wchar_t *__restrict __s2, size_t __n, |
96 | size_t __ns1), __wmempcpy_chk) |
97 | __warnattr ("wmempcpy called with length bigger than size of destination " |
98 | "buffer" ); |
99 | |
100 | __fortify_function wchar_t * |
101 | __NTH (wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, |
102 | size_t __n)) |
103 | { |
104 | if (__glibc_objsize0 (__s1) != (size_t) -1) |
105 | { |
106 | if (!__builtin_constant_p (__n)) |
107 | return __wmempcpy_chk (__s1, __s2, __n, |
108 | __glibc_objsize0 (__s1) / sizeof (wchar_t)); |
109 | |
110 | if (__n > __glibc_objsize0 (__s1) / sizeof (wchar_t)) |
111 | return __wmempcpy_chk_warn (__s1, __s2, __n, |
112 | (__glibc_objsize0 (__s1) |
113 | / sizeof (wchar_t))); |
114 | } |
115 | return __wmempcpy_alias (__s1, __s2, __n); |
116 | } |
117 | #endif |
118 | |
119 | |
120 | extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n, |
121 | size_t __ns) __THROW; |
122 | extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c, |
123 | size_t __n), wmemset); |
124 | extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn, |
125 | (wchar_t *__s, wchar_t __c, size_t __n, |
126 | size_t __ns), __wmemset_chk) |
127 | __warnattr ("wmemset called with length bigger than size of destination " |
128 | "buffer" ); |
129 | |
130 | __fortify_function wchar_t * |
131 | __NTH (wmemset (wchar_t *__s, wchar_t __c, size_t __n)) |
132 | { |
133 | if (__glibc_objsize0 (__s) != (size_t) -1) |
134 | { |
135 | if (!__builtin_constant_p (__n)) |
136 | return __wmemset_chk (__s, __c, __n, |
137 | __glibc_objsize0 (__s) / sizeof (wchar_t)); |
138 | |
139 | if (__n > __glibc_objsize0 (__s) / sizeof (wchar_t)) |
140 | return __wmemset_chk_warn (__s, __c, __n, |
141 | __glibc_objsize0 (__s) / sizeof (wchar_t)); |
142 | } |
143 | return __wmemset_alias (__s, __c, __n); |
144 | } |
145 | |
146 | |
147 | extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest, |
148 | const wchar_t *__restrict __src, |
149 | size_t __n) __THROW; |
150 | extern wchar_t *__REDIRECT_NTH (__wcscpy_alias, |
151 | (wchar_t *__restrict __dest, |
152 | const wchar_t *__restrict __src), wcscpy); |
153 | |
154 | __fortify_function wchar_t * |
155 | __NTH (wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) |
156 | { |
157 | if (__glibc_objsize (__dest) != (size_t) -1) |
158 | return __wcscpy_chk (__dest, __src, |
159 | __glibc_objsize (__dest) / sizeof (wchar_t)); |
160 | return __wcscpy_alias (__dest, __src); |
161 | } |
162 | |
163 | |
164 | extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest, |
165 | const wchar_t *__restrict __src, |
166 | size_t __destlen) __THROW; |
167 | extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias, |
168 | (wchar_t *__restrict __dest, |
169 | const wchar_t *__restrict __src), wcpcpy); |
170 | |
171 | __fortify_function wchar_t * |
172 | __NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) |
173 | { |
174 | if (__glibc_objsize (__dest) != (size_t) -1) |
175 | return __wcpcpy_chk (__dest, __src, |
176 | __glibc_objsize (__dest) / sizeof (wchar_t)); |
177 | return __wcpcpy_alias (__dest, __src); |
178 | } |
179 | |
180 | |
181 | extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest, |
182 | const wchar_t *__restrict __src, size_t __n, |
183 | size_t __destlen) __THROW; |
184 | extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias, |
185 | (wchar_t *__restrict __dest, |
186 | const wchar_t *__restrict __src, |
187 | size_t __n), wcsncpy); |
188 | extern wchar_t *__REDIRECT_NTH (__wcsncpy_chk_warn, |
189 | (wchar_t *__restrict __dest, |
190 | const wchar_t *__restrict __src, |
191 | size_t __n, size_t __destlen), __wcsncpy_chk) |
192 | __warnattr ("wcsncpy called with length bigger than size of destination " |
193 | "buffer" ); |
194 | |
195 | __fortify_function wchar_t * |
196 | __NTH (wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, |
197 | size_t __n)) |
198 | { |
199 | if (__glibc_objsize (__dest) != (size_t) -1) |
200 | { |
201 | if (!__builtin_constant_p (__n)) |
202 | return __wcsncpy_chk (__dest, __src, __n, |
203 | __glibc_objsize (__dest) / sizeof (wchar_t)); |
204 | if (__n > __glibc_objsize (__dest) / sizeof (wchar_t)) |
205 | return __wcsncpy_chk_warn (__dest, __src, __n, |
206 | (__glibc_objsize (__dest) |
207 | / sizeof (wchar_t))); |
208 | } |
209 | return __wcsncpy_alias (__dest, __src, __n); |
210 | } |
211 | |
212 | |
213 | extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest, |
214 | const wchar_t *__restrict __src, size_t __n, |
215 | size_t __destlen) __THROW; |
216 | extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias, |
217 | (wchar_t *__restrict __dest, |
218 | const wchar_t *__restrict __src, |
219 | size_t __n), wcpncpy); |
220 | extern wchar_t *__REDIRECT_NTH (__wcpncpy_chk_warn, |
221 | (wchar_t *__restrict __dest, |
222 | const wchar_t *__restrict __src, |
223 | size_t __n, size_t __destlen), __wcpncpy_chk) |
224 | __warnattr ("wcpncpy called with length bigger than size of destination " |
225 | "buffer" ); |
226 | |
227 | __fortify_function wchar_t * |
228 | __NTH (wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, |
229 | size_t __n)) |
230 | { |
231 | if (__glibc_objsize (__dest) != (size_t) -1) |
232 | { |
233 | if (!__builtin_constant_p (__n)) |
234 | return __wcpncpy_chk (__dest, __src, __n, |
235 | __glibc_objsize (__dest) / sizeof (wchar_t)); |
236 | if (__n > __glibc_objsize (__dest) / sizeof (wchar_t)) |
237 | return __wcpncpy_chk_warn (__dest, __src, __n, |
238 | (__glibc_objsize (__dest) |
239 | / sizeof (wchar_t))); |
240 | } |
241 | return __wcpncpy_alias (__dest, __src, __n); |
242 | } |
243 | |
244 | |
245 | extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest, |
246 | const wchar_t *__restrict __src, |
247 | size_t __destlen) __THROW; |
248 | extern wchar_t *__REDIRECT_NTH (__wcscat_alias, |
249 | (wchar_t *__restrict __dest, |
250 | const wchar_t *__restrict __src), wcscat); |
251 | |
252 | __fortify_function wchar_t * |
253 | __NTH (wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) |
254 | { |
255 | if (__glibc_objsize (__dest) != (size_t) -1) |
256 | return __wcscat_chk (__dest, __src, |
257 | __glibc_objsize (__dest) / sizeof (wchar_t)); |
258 | return __wcscat_alias (__dest, __src); |
259 | } |
260 | |
261 | |
262 | extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest, |
263 | const wchar_t *__restrict __src, |
264 | size_t __n, size_t __destlen) __THROW; |
265 | extern wchar_t *__REDIRECT_NTH (__wcsncat_alias, |
266 | (wchar_t *__restrict __dest, |
267 | const wchar_t *__restrict __src, |
268 | size_t __n), wcsncat); |
269 | |
270 | __fortify_function wchar_t * |
271 | __NTH (wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src, |
272 | size_t __n)) |
273 | { |
274 | if (__glibc_objsize (__dest) != (size_t) -1) |
275 | return __wcsncat_chk (__dest, __src, __n, |
276 | __glibc_objsize (__dest) / sizeof (wchar_t)); |
277 | return __wcsncat_alias (__dest, __src, __n); |
278 | } |
279 | |
280 | |
281 | extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n, |
282 | int __flag, size_t __s_len, |
283 | const wchar_t *__restrict __format, ...) |
284 | __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */; |
285 | |
286 | extern int __REDIRECT_NTH_LDBL (__swprintf_alias, |
287 | (wchar_t *__restrict __s, size_t __n, |
288 | const wchar_t *__restrict __fmt, ...), |
289 | swprintf); |
290 | |
291 | #ifdef __va_arg_pack |
292 | __fortify_function int |
293 | __NTH (swprintf (wchar_t *__restrict __s, size_t __n, |
294 | const wchar_t *__restrict __fmt, ...)) |
295 | { |
296 | if (__glibc_objsize (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) |
297 | return __swprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, |
298 | __glibc_objsize (__s) / sizeof (wchar_t), |
299 | __fmt, __va_arg_pack ()); |
300 | return __swprintf_alias (__s, __n, __fmt, __va_arg_pack ()); |
301 | } |
302 | #elif !defined __cplusplus |
303 | /* XXX We might want to have support in gcc for swprintf. */ |
304 | # define swprintf(s, n, ...) \ |
305 | (__glibc_objsize (s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1 \ |
306 | ? __swprintf_chk (s, n, __USE_FORTIFY_LEVEL - 1, \ |
307 | __glibc_objsize (s) / sizeof (wchar_t), __VA_ARGS__) \ |
308 | : swprintf (s, n, __VA_ARGS__)) |
309 | #endif |
310 | |
311 | extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, |
312 | int __flag, size_t __s_len, |
313 | const wchar_t *__restrict __format, |
314 | __gnuc_va_list __arg) |
315 | __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; |
316 | |
317 | extern int __REDIRECT_NTH_LDBL (__vswprintf_alias, |
318 | (wchar_t *__restrict __s, size_t __n, |
319 | const wchar_t *__restrict __fmt, |
320 | __gnuc_va_list __ap), vswprintf); |
321 | |
322 | __fortify_function int |
323 | __NTH (vswprintf (wchar_t *__restrict __s, size_t __n, |
324 | const wchar_t *__restrict __fmt, __gnuc_va_list __ap)) |
325 | { |
326 | if (__glibc_objsize (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) |
327 | return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, |
328 | __glibc_objsize (__s) / sizeof (wchar_t), __fmt, |
329 | __ap); |
330 | return __vswprintf_alias (__s, __n, __fmt, __ap); |
331 | } |
332 | |
333 | |
334 | #if __USE_FORTIFY_LEVEL > 1 |
335 | |
336 | extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag, |
337 | const wchar_t *__restrict __format, ...); |
338 | extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format, |
339 | ...); |
340 | extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag, |
341 | const wchar_t *__restrict __format, |
342 | __gnuc_va_list __ap); |
343 | extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format, |
344 | __gnuc_va_list __ap); |
345 | |
346 | # ifdef __va_arg_pack |
347 | __fortify_function int |
348 | wprintf (const wchar_t *__restrict __fmt, ...) |
349 | { |
350 | return __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); |
351 | } |
352 | |
353 | __fortify_function int |
354 | fwprintf (__FILE *__restrict __stream, const wchar_t *__restrict __fmt, ...) |
355 | { |
356 | return __fwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, |
357 | __va_arg_pack ()); |
358 | } |
359 | # elif !defined __cplusplus |
360 | # define wprintf(...) \ |
361 | __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
362 | # define fwprintf(stream, ...) \ |
363 | __fwprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
364 | # endif |
365 | |
366 | __fortify_function int |
367 | vwprintf (const wchar_t *__restrict __fmt, __gnuc_va_list __ap) |
368 | { |
369 | return __vwprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap); |
370 | } |
371 | |
372 | __fortify_function int |
373 | vfwprintf (__FILE *__restrict __stream, |
374 | const wchar_t *__restrict __fmt, __gnuc_va_list __ap) |
375 | { |
376 | return __vfwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); |
377 | } |
378 | |
379 | #endif |
380 | |
381 | extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n, |
382 | __FILE *__restrict __stream) __wur; |
383 | extern wchar_t *__REDIRECT (__fgetws_alias, |
384 | (wchar_t *__restrict __s, int __n, |
385 | __FILE *__restrict __stream), fgetws) __wur; |
386 | extern wchar_t *__REDIRECT (__fgetws_chk_warn, |
387 | (wchar_t *__restrict __s, size_t __size, int __n, |
388 | __FILE *__restrict __stream), __fgetws_chk) |
389 | __wur __warnattr ("fgetws called with bigger size than length " |
390 | "of destination buffer" ); |
391 | |
392 | __fortify_function __wur wchar_t * |
393 | fgetws (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream) |
394 | { |
395 | if (__glibc_objsize (__s) != (size_t) -1) |
396 | { |
397 | if (!__builtin_constant_p (__n) || __n <= 0) |
398 | return __fgetws_chk (__s, __glibc_objsize (__s) / sizeof (wchar_t), |
399 | __n, __stream); |
400 | |
401 | if ((size_t) __n > __glibc_objsize (__s) / sizeof (wchar_t)) |
402 | return __fgetws_chk_warn (__s, |
403 | __glibc_objsize (__s) / sizeof (wchar_t), |
404 | __n, __stream); |
405 | } |
406 | return __fgetws_alias (__s, __n, __stream); |
407 | } |
408 | |
409 | #ifdef __USE_GNU |
410 | extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size, |
411 | int __n, __FILE *__restrict __stream) |
412 | __wur; |
413 | extern wchar_t *__REDIRECT (__fgetws_unlocked_alias, |
414 | (wchar_t *__restrict __s, int __n, |
415 | __FILE *__restrict __stream), fgetws_unlocked) |
416 | __wur; |
417 | extern wchar_t *__REDIRECT (__fgetws_unlocked_chk_warn, |
418 | (wchar_t *__restrict __s, size_t __size, int __n, |
419 | __FILE *__restrict __stream), |
420 | __fgetws_unlocked_chk) |
421 | __wur __warnattr ("fgetws_unlocked called with bigger size than length " |
422 | "of destination buffer" ); |
423 | |
424 | __fortify_function __wur wchar_t * |
425 | fgetws_unlocked (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream) |
426 | { |
427 | if (__glibc_objsize (__s) != (size_t) -1) |
428 | { |
429 | if (!__builtin_constant_p (__n) || __n <= 0) |
430 | return __fgetws_unlocked_chk (__s, |
431 | __glibc_objsize (__s) / sizeof (wchar_t), |
432 | __n, __stream); |
433 | |
434 | if ((size_t) __n > __glibc_objsize (__s) / sizeof (wchar_t)) |
435 | return __fgetws_unlocked_chk_warn (__s, |
436 | (__glibc_objsize (__s) |
437 | / sizeof (wchar_t)), |
438 | __n, __stream); |
439 | } |
440 | return __fgetws_unlocked_alias (__s, __n, __stream); |
441 | } |
442 | #endif |
443 | |
444 | |
445 | extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar, |
446 | mbstate_t *__restrict __p, |
447 | size_t __buflen) __THROW __wur; |
448 | extern size_t __REDIRECT_NTH (__wcrtomb_alias, |
449 | (char *__restrict __s, wchar_t __wchar, |
450 | mbstate_t *__restrict __ps), wcrtomb) __wur; |
451 | |
452 | __fortify_function __wur size_t |
453 | __NTH (wcrtomb (char *__restrict __s, wchar_t __wchar, |
454 | mbstate_t *__restrict __ps)) |
455 | { |
456 | /* We would have to include <limits.h> to get a definition of MB_LEN_MAX. |
457 | But this would only disturb the namespace. So we define our own |
458 | version here. */ |
459 | #define __WCHAR_MB_LEN_MAX 16 |
460 | #if defined MB_LEN_MAX && MB_LEN_MAX != __WCHAR_MB_LEN_MAX |
461 | # error "Assumed value of MB_LEN_MAX wrong" |
462 | #endif |
463 | if (__glibc_objsize (__s) != (size_t) -1 |
464 | && __WCHAR_MB_LEN_MAX > __glibc_objsize (__s)) |
465 | return __wcrtomb_chk (__s, __wchar, __ps, __glibc_objsize (__s)); |
466 | return __wcrtomb_alias (__s, __wchar, __ps); |
467 | } |
468 | |
469 | |
470 | extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst, |
471 | const char **__restrict __src, |
472 | size_t __len, mbstate_t *__restrict __ps, |
473 | size_t __dstlen) __THROW; |
474 | extern size_t __REDIRECT_NTH (__mbsrtowcs_alias, |
475 | (wchar_t *__restrict __dst, |
476 | const char **__restrict __src, |
477 | size_t __len, mbstate_t *__restrict __ps), |
478 | mbsrtowcs); |
479 | extern size_t __REDIRECT_NTH (__mbsrtowcs_chk_warn, |
480 | (wchar_t *__restrict __dst, |
481 | const char **__restrict __src, |
482 | size_t __len, mbstate_t *__restrict __ps, |
483 | size_t __dstlen), __mbsrtowcs_chk) |
484 | __warnattr ("mbsrtowcs called with dst buffer smaller than len " |
485 | "* sizeof (wchar_t)" ); |
486 | |
487 | __fortify_function size_t |
488 | __NTH (mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, |
489 | size_t __len, mbstate_t *__restrict __ps)) |
490 | { |
491 | if (__glibc_objsize (__dst) != (size_t) -1) |
492 | { |
493 | if (!__builtin_constant_p (__len)) |
494 | return __mbsrtowcs_chk (__dst, __src, __len, __ps, |
495 | __glibc_objsize (__dst) / sizeof (wchar_t)); |
496 | |
497 | if (__len > __glibc_objsize (__dst) / sizeof (wchar_t)) |
498 | return __mbsrtowcs_chk_warn (__dst, __src, __len, __ps, |
499 | (__glibc_objsize (__dst) |
500 | / sizeof (wchar_t))); |
501 | } |
502 | return __mbsrtowcs_alias (__dst, __src, __len, __ps); |
503 | } |
504 | |
505 | |
506 | extern size_t __wcsrtombs_chk (char *__restrict __dst, |
507 | const wchar_t **__restrict __src, |
508 | size_t __len, mbstate_t *__restrict __ps, |
509 | size_t __dstlen) __THROW; |
510 | extern size_t __REDIRECT_NTH (__wcsrtombs_alias, |
511 | (char *__restrict __dst, |
512 | const wchar_t **__restrict __src, |
513 | size_t __len, mbstate_t *__restrict __ps), |
514 | wcsrtombs); |
515 | extern size_t __REDIRECT_NTH (__wcsrtombs_chk_warn, |
516 | (char *__restrict __dst, |
517 | const wchar_t **__restrict __src, |
518 | size_t __len, mbstate_t *__restrict __ps, |
519 | size_t __dstlen), __wcsrtombs_chk) |
520 | __warnattr ("wcsrtombs called with dst buffer smaller than len" ); |
521 | |
522 | __fortify_function size_t |
523 | __NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src, |
524 | size_t __len, mbstate_t *__restrict __ps)) |
525 | { |
526 | if (__glibc_objsize (__dst) != (size_t) -1) |
527 | { |
528 | if (!__builtin_constant_p (__len)) |
529 | return __wcsrtombs_chk (__dst, __src, __len, __ps, |
530 | __glibc_objsize (__dst)); |
531 | |
532 | if (__len > __glibc_objsize (__dst)) |
533 | return __wcsrtombs_chk_warn (__dst, __src, __len, __ps, |
534 | __glibc_objsize (__dst)); |
535 | } |
536 | return __wcsrtombs_alias (__dst, __src, __len, __ps); |
537 | } |
538 | |
539 | |
540 | #ifdef __USE_GNU |
541 | extern size_t __mbsnrtowcs_chk (wchar_t *__restrict __dst, |
542 | const char **__restrict __src, size_t __nmc, |
543 | size_t __len, mbstate_t *__restrict __ps, |
544 | size_t __dstlen) __THROW; |
545 | extern size_t __REDIRECT_NTH (__mbsnrtowcs_alias, |
546 | (wchar_t *__restrict __dst, |
547 | const char **__restrict __src, size_t __nmc, |
548 | size_t __len, mbstate_t *__restrict __ps), |
549 | mbsnrtowcs); |
550 | extern size_t __REDIRECT_NTH (__mbsnrtowcs_chk_warn, |
551 | (wchar_t *__restrict __dst, |
552 | const char **__restrict __src, size_t __nmc, |
553 | size_t __len, mbstate_t *__restrict __ps, |
554 | size_t __dstlen), __mbsnrtowcs_chk) |
555 | __warnattr ("mbsnrtowcs called with dst buffer smaller than len " |
556 | "* sizeof (wchar_t)" ); |
557 | |
558 | __fortify_function size_t |
559 | __NTH (mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, |
560 | size_t __nmc, size_t __len, mbstate_t *__restrict __ps)) |
561 | { |
562 | if (__glibc_objsize (__dst) != (size_t) -1) |
563 | { |
564 | if (!__builtin_constant_p (__len)) |
565 | return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps, |
566 | __glibc_objsize (__dst) / sizeof (wchar_t)); |
567 | |
568 | if (__len > __glibc_objsize (__dst) / sizeof (wchar_t)) |
569 | return __mbsnrtowcs_chk_warn (__dst, __src, __nmc, __len, __ps, |
570 | (__glibc_objsize (__dst) |
571 | / sizeof (wchar_t))); |
572 | } |
573 | return __mbsnrtowcs_alias (__dst, __src, __nmc, __len, __ps); |
574 | } |
575 | |
576 | |
577 | extern size_t __wcsnrtombs_chk (char *__restrict __dst, |
578 | const wchar_t **__restrict __src, |
579 | size_t __nwc, size_t __len, |
580 | mbstate_t *__restrict __ps, size_t __dstlen) |
581 | __THROW; |
582 | extern size_t __REDIRECT_NTH (__wcsnrtombs_alias, |
583 | (char *__restrict __dst, |
584 | const wchar_t **__restrict __src, |
585 | size_t __nwc, size_t __len, |
586 | mbstate_t *__restrict __ps), wcsnrtombs); |
587 | extern size_t __REDIRECT_NTH (__wcsnrtombs_chk_warn, |
588 | (char *__restrict __dst, |
589 | const wchar_t **__restrict __src, |
590 | size_t __nwc, size_t __len, |
591 | mbstate_t *__restrict __ps, |
592 | size_t __dstlen), __wcsnrtombs_chk) |
593 | __warnattr ("wcsnrtombs called with dst buffer smaller than len" ); |
594 | |
595 | __fortify_function size_t |
596 | __NTH (wcsnrtombs (char *__restrict __dst, const wchar_t **__restrict __src, |
597 | size_t __nwc, size_t __len, mbstate_t *__restrict __ps)) |
598 | { |
599 | if (__glibc_objsize (__dst) != (size_t) -1) |
600 | { |
601 | if (!__builtin_constant_p (__len)) |
602 | return __wcsnrtombs_chk (__dst, __src, __nwc, __len, __ps, |
603 | __glibc_objsize (__dst)); |
604 | |
605 | if (__len > __glibc_objsize (__dst)) |
606 | return __wcsnrtombs_chk_warn (__dst, __src, __nwc, __len, __ps, |
607 | __glibc_objsize (__dst)); |
608 | } |
609 | return __wcsnrtombs_alias (__dst, __src, __nwc, __len, __ps); |
610 | } |
611 | #endif |
612 | |