xref: /freebsd/lib/libc/tests/secure/fortify_wchar_test.c (revision b670c9bafc0e31c7609969bf374b2e80bdc00211)
1 /* @generated by `generate-fortify-tests.lua "wchar"` */
2 
3 #define	_FORTIFY_SOURCE	2
4 #define	TMPFILE_SIZE	(1024 * 32)
5 
6 #include <sys/param.h>
7 #include <sys/jail.h>
8 #include <sys/random.h>
9 #include <sys/resource.h>
10 #include <sys/select.h>
11 #include <sys/socket.h>
12 #include <sys/time.h>
13 #include <sys/uio.h>
14 #include <sys/wait.h>
15 #include <dirent.h>
16 #include <errno.h>
17 #include <fcntl.h>
18 #include <limits.h>
19 #include <poll.h>
20 #include <signal.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <strings.h>
25 #include <sysexits.h>
26 #include <unistd.h>
27 #include <wchar.h>
28 #include <atf-c.h>
29 
30 static FILE * __unused
31 new_fp(size_t __len)
32 {
33 	static char fpbuf[LINE_MAX];
34 	FILE *fp;
35 
36 	ATF_REQUIRE(__len <= sizeof(fpbuf));
37 
38 	memset(fpbuf, 'A', sizeof(fpbuf) - 1);
39 	fpbuf[sizeof(fpbuf) - 1] = '\0';
40 
41 	fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
42 	ATF_REQUIRE(fp != NULL);
43 
44 	return (fp);
45 }
46 
47 /*
48  * Create a new symlink to use for readlink(2) style tests, we'll just use a
49  * random target name to have something interesting to look at.
50  */
51 static const char * __unused
52 new_symlink(size_t __len)
53 {
54 	static const char linkname[] = "link";
55 	char target[MAXNAMLEN];
56 	int error;
57 
58 	ATF_REQUIRE(__len <= sizeof(target));
59 
60 	arc4random_buf(target, sizeof(target));
61 
62 	error = unlink(linkname);
63 	ATF_REQUIRE(error == 0 || errno == ENOENT);
64 
65 	error = symlink(target, linkname);
66 	ATF_REQUIRE(error == 0);
67 
68 	return (linkname);
69 }
70 
71 /*
72  * For our purposes, first descriptor will be the reader; we'll send both
73  * raw data and a control message over it so that the result can be used for
74  * any of our recv*() tests.
75  */
76 static void __unused
77 new_socket(int sock[2])
78 {
79 	unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
80 	static char sockbuf[256];
81 	ssize_t rv;
82 	size_t total = 0;
83 	struct msghdr hdr = { 0 };
84 	struct cmsghdr *cmsg;
85 	int error, fd;
86 
87 	error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
88 	ATF_REQUIRE(error == 0);
89 
90 	while (total != sizeof(sockbuf)) {
91 		rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
92 
93 		ATF_REQUIRE_MSG(rv > 0,
94 		    "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
95 		    rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
96 		ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
97 		    "%zd exceeds total %zu", rv, sizeof(sockbuf));
98 		total += rv;
99 	}
100 
101 	hdr.msg_control = ctrl;
102 	hdr.msg_controllen = sizeof(ctrl);
103 
104 	cmsg = CMSG_FIRSTHDR(&hdr);
105 	cmsg->cmsg_level = SOL_SOCKET;
106 	cmsg->cmsg_type = SCM_RIGHTS;
107 	cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
108 	fd = STDIN_FILENO;
109 	memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
110 
111 	error = sendmsg(sock[1], &hdr, 0);
112 	ATF_REQUIRE(error != -1);
113 }
114 
115 /*
116  * Constructs a tmpfile that we can use for testing read(2) and friends.
117  */
118 static int __unused
119 new_tmpfile(void)
120 {
121 	char buf[1024];
122 	ssize_t rv;
123 	size_t written;
124 	int fd;
125 
126 	fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
127 	ATF_REQUIRE(fd >= 0);
128 
129 	written = 0;
130 	while (written < TMPFILE_SIZE) {
131 		rv = write(fd, buf, sizeof(buf));
132 		ATF_REQUIRE(rv > 0);
133 
134 		written += rv;
135 	}
136 
137 	ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
138 	return (fd);
139 }
140 
141 static void
142 disable_coredumps(void)
143 {
144 	struct rlimit rl = { 0 };
145 
146 	if (setrlimit(RLIMIT_CORE, &rl) == -1)
147 		_exit(EX_OSERR);
148 }
149 
150 /*
151  * Replaces stdin with a file that we can actually read from, for tests where
152  * we want a FILE * or fd that we can get data from.
153  */
154 static void __unused
155 replace_stdin(void)
156 {
157 	int fd;
158 
159 	fd = new_tmpfile();
160 
161 	(void)dup2(fd, STDIN_FILENO);
162 	if (fd != STDIN_FILENO)
163 		close(fd);
164 }
165 
166 ATF_TC(wmemcpy_before_end);
167 ATF_TC_HEAD(wmemcpy_before_end, tc)
168 {
169 }
170 ATF_TC_BODY(wmemcpy_before_end, tc)
171 {
172 #define BUF &__stack.__buf
173 	struct {
174 		uint8_t padding_l;
175 		wchar_t __buf[42];
176 		uint8_t padding_r;
177 	} __stack;
178 	const size_t __bufsz __unused = sizeof(__stack.__buf);
179 	const size_t __len = 42 - 1;
180 	const size_t __idx __unused = __len - 1;
181 	wchar_t src[__len + 10];
182 
183 	wmemcpy(__stack.__buf, src, __len);
184 #undef BUF
185 
186 }
187 
188 ATF_TC(wmemcpy_end);
189 ATF_TC_HEAD(wmemcpy_end, tc)
190 {
191 }
192 ATF_TC_BODY(wmemcpy_end, tc)
193 {
194 #define BUF &__stack.__buf
195 	struct {
196 		uint8_t padding_l;
197 		wchar_t __buf[42];
198 		uint8_t padding_r;
199 	} __stack;
200 	const size_t __bufsz __unused = sizeof(__stack.__buf);
201 	const size_t __len = 42;
202 	const size_t __idx __unused = __len - 1;
203 	wchar_t src[__len + 10];
204 
205 	wmemcpy(__stack.__buf, src, __len);
206 #undef BUF
207 
208 }
209 
210 ATF_TC(wmemcpy_heap_before_end);
211 ATF_TC_HEAD(wmemcpy_heap_before_end, tc)
212 {
213 }
214 ATF_TC_BODY(wmemcpy_heap_before_end, tc)
215 {
216 #define BUF __stack.__buf
217 	struct {
218 		uint8_t padding_l;
219 		wchar_t * __buf;
220 		uint8_t padding_r;
221 	} __stack;
222 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
223 	const size_t __len = 42 - 1;
224 	const size_t __idx __unused = __len - 1;
225 	wchar_t src[__len + 10];
226 
227 	__stack.__buf = malloc(__bufsz);
228 
229 	wmemcpy(__stack.__buf, src, __len);
230 #undef BUF
231 
232 }
233 
234 ATF_TC(wmemcpy_heap_end);
235 ATF_TC_HEAD(wmemcpy_heap_end, tc)
236 {
237 }
238 ATF_TC_BODY(wmemcpy_heap_end, tc)
239 {
240 #define BUF __stack.__buf
241 	struct {
242 		uint8_t padding_l;
243 		wchar_t * __buf;
244 		uint8_t padding_r;
245 	} __stack;
246 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
247 	const size_t __len = 42;
248 	const size_t __idx __unused = __len - 1;
249 	wchar_t src[__len + 10];
250 
251 	__stack.__buf = malloc(__bufsz);
252 
253 	wmemcpy(__stack.__buf, src, __len);
254 #undef BUF
255 
256 }
257 
258 ATF_TC(wmemcpy_heap_after_end);
259 ATF_TC_HEAD(wmemcpy_heap_after_end, tc)
260 {
261 }
262 ATF_TC_BODY(wmemcpy_heap_after_end, tc)
263 {
264 #define BUF __stack.__buf
265 	struct {
266 		uint8_t padding_l;
267 		wchar_t * __buf;
268 		uint8_t padding_r;
269 	} __stack;
270 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
271 	const size_t __len = 42 + 1;
272 	const size_t __idx __unused = __len - 1;
273 	pid_t __child;
274 	int __status;
275 	wchar_t src[__len + 10];
276 
277 	__child = fork();
278 	ATF_REQUIRE(__child >= 0);
279 	if (__child > 0)
280 		goto monitor;
281 
282 	/* Child */
283 	disable_coredumps();
284 	__stack.__buf = malloc(__bufsz);
285 
286 	wmemcpy(__stack.__buf, src, __len);
287 	_exit(EX_SOFTWARE);	/* Should have aborted. */
288 
289 monitor:
290 	while (waitpid(__child, &__status, 0) != __child) {
291 		ATF_REQUIRE_EQ(EINTR, errno);
292 	}
293 
294 	if (!WIFSIGNALED(__status)) {
295 		switch (WEXITSTATUS(__status)) {
296 		case EX_SOFTWARE:
297 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
298 			break;
299 		case EX_OSERR:
300 			atf_tc_fail("setrlimit(2) failed");
301 			break;
302 		default:
303 			atf_tc_fail("child exited with status %d",
304 			    WEXITSTATUS(__status));
305 		}
306 	} else {
307 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
308 	}
309 #undef BUF
310 
311 }
312 
313 ATF_TC(wmempcpy_before_end);
314 ATF_TC_HEAD(wmempcpy_before_end, tc)
315 {
316 }
317 ATF_TC_BODY(wmempcpy_before_end, tc)
318 {
319 #define BUF &__stack.__buf
320 	struct {
321 		uint8_t padding_l;
322 		wchar_t __buf[42];
323 		uint8_t padding_r;
324 	} __stack;
325 	const size_t __bufsz __unused = sizeof(__stack.__buf);
326 	const size_t __len = 42 - 1;
327 	const size_t __idx __unused = __len - 1;
328 	wchar_t src[__len + 10];
329 
330 	wmempcpy(__stack.__buf, src, __len);
331 #undef BUF
332 
333 }
334 
335 ATF_TC(wmempcpy_end);
336 ATF_TC_HEAD(wmempcpy_end, tc)
337 {
338 }
339 ATF_TC_BODY(wmempcpy_end, tc)
340 {
341 #define BUF &__stack.__buf
342 	struct {
343 		uint8_t padding_l;
344 		wchar_t __buf[42];
345 		uint8_t padding_r;
346 	} __stack;
347 	const size_t __bufsz __unused = sizeof(__stack.__buf);
348 	const size_t __len = 42;
349 	const size_t __idx __unused = __len - 1;
350 	wchar_t src[__len + 10];
351 
352 	wmempcpy(__stack.__buf, src, __len);
353 #undef BUF
354 
355 }
356 
357 ATF_TC(wmempcpy_heap_before_end);
358 ATF_TC_HEAD(wmempcpy_heap_before_end, tc)
359 {
360 }
361 ATF_TC_BODY(wmempcpy_heap_before_end, tc)
362 {
363 #define BUF __stack.__buf
364 	struct {
365 		uint8_t padding_l;
366 		wchar_t * __buf;
367 		uint8_t padding_r;
368 	} __stack;
369 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
370 	const size_t __len = 42 - 1;
371 	const size_t __idx __unused = __len - 1;
372 	wchar_t src[__len + 10];
373 
374 	__stack.__buf = malloc(__bufsz);
375 
376 	wmempcpy(__stack.__buf, src, __len);
377 #undef BUF
378 
379 }
380 
381 ATF_TC(wmempcpy_heap_end);
382 ATF_TC_HEAD(wmempcpy_heap_end, tc)
383 {
384 }
385 ATF_TC_BODY(wmempcpy_heap_end, tc)
386 {
387 #define BUF __stack.__buf
388 	struct {
389 		uint8_t padding_l;
390 		wchar_t * __buf;
391 		uint8_t padding_r;
392 	} __stack;
393 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
394 	const size_t __len = 42;
395 	const size_t __idx __unused = __len - 1;
396 	wchar_t src[__len + 10];
397 
398 	__stack.__buf = malloc(__bufsz);
399 
400 	wmempcpy(__stack.__buf, src, __len);
401 #undef BUF
402 
403 }
404 
405 ATF_TC(wmempcpy_heap_after_end);
406 ATF_TC_HEAD(wmempcpy_heap_after_end, tc)
407 {
408 }
409 ATF_TC_BODY(wmempcpy_heap_after_end, tc)
410 {
411 #define BUF __stack.__buf
412 	struct {
413 		uint8_t padding_l;
414 		wchar_t * __buf;
415 		uint8_t padding_r;
416 	} __stack;
417 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
418 	const size_t __len = 42 + 1;
419 	const size_t __idx __unused = __len - 1;
420 	pid_t __child;
421 	int __status;
422 	wchar_t src[__len + 10];
423 
424 	__child = fork();
425 	ATF_REQUIRE(__child >= 0);
426 	if (__child > 0)
427 		goto monitor;
428 
429 	/* Child */
430 	disable_coredumps();
431 	__stack.__buf = malloc(__bufsz);
432 
433 	wmempcpy(__stack.__buf, src, __len);
434 	_exit(EX_SOFTWARE);	/* Should have aborted. */
435 
436 monitor:
437 	while (waitpid(__child, &__status, 0) != __child) {
438 		ATF_REQUIRE_EQ(EINTR, errno);
439 	}
440 
441 	if (!WIFSIGNALED(__status)) {
442 		switch (WEXITSTATUS(__status)) {
443 		case EX_SOFTWARE:
444 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
445 			break;
446 		case EX_OSERR:
447 			atf_tc_fail("setrlimit(2) failed");
448 			break;
449 		default:
450 			atf_tc_fail("child exited with status %d",
451 			    WEXITSTATUS(__status));
452 		}
453 	} else {
454 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
455 	}
456 #undef BUF
457 
458 }
459 
460 ATF_TC(wmemmove_before_end);
461 ATF_TC_HEAD(wmemmove_before_end, tc)
462 {
463 }
464 ATF_TC_BODY(wmemmove_before_end, tc)
465 {
466 #define BUF &__stack.__buf
467 	struct {
468 		uint8_t padding_l;
469 		wchar_t __buf[42];
470 		uint8_t padding_r;
471 	} __stack;
472 	const size_t __bufsz __unused = sizeof(__stack.__buf);
473 	const size_t __len = 42 - 1;
474 	const size_t __idx __unused = __len - 1;
475 	wchar_t src[__len + 10];
476 
477 	wmemmove(__stack.__buf, src, __len);
478 #undef BUF
479 
480 }
481 
482 ATF_TC(wmemmove_end);
483 ATF_TC_HEAD(wmemmove_end, tc)
484 {
485 }
486 ATF_TC_BODY(wmemmove_end, tc)
487 {
488 #define BUF &__stack.__buf
489 	struct {
490 		uint8_t padding_l;
491 		wchar_t __buf[42];
492 		uint8_t padding_r;
493 	} __stack;
494 	const size_t __bufsz __unused = sizeof(__stack.__buf);
495 	const size_t __len = 42;
496 	const size_t __idx __unused = __len - 1;
497 	wchar_t src[__len + 10];
498 
499 	wmemmove(__stack.__buf, src, __len);
500 #undef BUF
501 
502 }
503 
504 ATF_TC(wmemmove_heap_before_end);
505 ATF_TC_HEAD(wmemmove_heap_before_end, tc)
506 {
507 }
508 ATF_TC_BODY(wmemmove_heap_before_end, tc)
509 {
510 #define BUF __stack.__buf
511 	struct {
512 		uint8_t padding_l;
513 		wchar_t * __buf;
514 		uint8_t padding_r;
515 	} __stack;
516 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
517 	const size_t __len = 42 - 1;
518 	const size_t __idx __unused = __len - 1;
519 	wchar_t src[__len + 10];
520 
521 	__stack.__buf = malloc(__bufsz);
522 
523 	wmemmove(__stack.__buf, src, __len);
524 #undef BUF
525 
526 }
527 
528 ATF_TC(wmemmove_heap_end);
529 ATF_TC_HEAD(wmemmove_heap_end, tc)
530 {
531 }
532 ATF_TC_BODY(wmemmove_heap_end, tc)
533 {
534 #define BUF __stack.__buf
535 	struct {
536 		uint8_t padding_l;
537 		wchar_t * __buf;
538 		uint8_t padding_r;
539 	} __stack;
540 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
541 	const size_t __len = 42;
542 	const size_t __idx __unused = __len - 1;
543 	wchar_t src[__len + 10];
544 
545 	__stack.__buf = malloc(__bufsz);
546 
547 	wmemmove(__stack.__buf, src, __len);
548 #undef BUF
549 
550 }
551 
552 ATF_TC(wmemmove_heap_after_end);
553 ATF_TC_HEAD(wmemmove_heap_after_end, tc)
554 {
555 }
556 ATF_TC_BODY(wmemmove_heap_after_end, tc)
557 {
558 #define BUF __stack.__buf
559 	struct {
560 		uint8_t padding_l;
561 		wchar_t * __buf;
562 		uint8_t padding_r;
563 	} __stack;
564 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
565 	const size_t __len = 42 + 1;
566 	const size_t __idx __unused = __len - 1;
567 	pid_t __child;
568 	int __status;
569 	wchar_t src[__len + 10];
570 
571 	__child = fork();
572 	ATF_REQUIRE(__child >= 0);
573 	if (__child > 0)
574 		goto monitor;
575 
576 	/* Child */
577 	disable_coredumps();
578 	__stack.__buf = malloc(__bufsz);
579 
580 	wmemmove(__stack.__buf, src, __len);
581 	_exit(EX_SOFTWARE);	/* Should have aborted. */
582 
583 monitor:
584 	while (waitpid(__child, &__status, 0) != __child) {
585 		ATF_REQUIRE_EQ(EINTR, errno);
586 	}
587 
588 	if (!WIFSIGNALED(__status)) {
589 		switch (WEXITSTATUS(__status)) {
590 		case EX_SOFTWARE:
591 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
592 			break;
593 		case EX_OSERR:
594 			atf_tc_fail("setrlimit(2) failed");
595 			break;
596 		default:
597 			atf_tc_fail("child exited with status %d",
598 			    WEXITSTATUS(__status));
599 		}
600 	} else {
601 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
602 	}
603 #undef BUF
604 
605 }
606 
607 ATF_TC(wmemset_before_end);
608 ATF_TC_HEAD(wmemset_before_end, tc)
609 {
610 }
611 ATF_TC_BODY(wmemset_before_end, tc)
612 {
613 #define BUF &__stack.__buf
614 	struct {
615 		uint8_t padding_l;
616 		wchar_t __buf[42];
617 		uint8_t padding_r;
618 	} __stack;
619 	const size_t __bufsz __unused = sizeof(__stack.__buf);
620 	const size_t __len = 42 - 1;
621 	const size_t __idx __unused = __len - 1;
622 
623 	wmemset(__stack.__buf, L'0', __len);
624 #undef BUF
625 
626 }
627 
628 ATF_TC(wmemset_end);
629 ATF_TC_HEAD(wmemset_end, tc)
630 {
631 }
632 ATF_TC_BODY(wmemset_end, tc)
633 {
634 #define BUF &__stack.__buf
635 	struct {
636 		uint8_t padding_l;
637 		wchar_t __buf[42];
638 		uint8_t padding_r;
639 	} __stack;
640 	const size_t __bufsz __unused = sizeof(__stack.__buf);
641 	const size_t __len = 42;
642 	const size_t __idx __unused = __len - 1;
643 
644 	wmemset(__stack.__buf, L'0', __len);
645 #undef BUF
646 
647 }
648 
649 ATF_TC(wmemset_heap_before_end);
650 ATF_TC_HEAD(wmemset_heap_before_end, tc)
651 {
652 }
653 ATF_TC_BODY(wmemset_heap_before_end, tc)
654 {
655 #define BUF __stack.__buf
656 	struct {
657 		uint8_t padding_l;
658 		wchar_t * __buf;
659 		uint8_t padding_r;
660 	} __stack;
661 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
662 	const size_t __len = 42 - 1;
663 	const size_t __idx __unused = __len - 1;
664 
665 	__stack.__buf = malloc(__bufsz);
666 
667 	wmemset(__stack.__buf, L'0', __len);
668 #undef BUF
669 
670 }
671 
672 ATF_TC(wmemset_heap_end);
673 ATF_TC_HEAD(wmemset_heap_end, tc)
674 {
675 }
676 ATF_TC_BODY(wmemset_heap_end, tc)
677 {
678 #define BUF __stack.__buf
679 	struct {
680 		uint8_t padding_l;
681 		wchar_t * __buf;
682 		uint8_t padding_r;
683 	} __stack;
684 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
685 	const size_t __len = 42;
686 	const size_t __idx __unused = __len - 1;
687 
688 	__stack.__buf = malloc(__bufsz);
689 
690 	wmemset(__stack.__buf, L'0', __len);
691 #undef BUF
692 
693 }
694 
695 ATF_TC(wmemset_heap_after_end);
696 ATF_TC_HEAD(wmemset_heap_after_end, tc)
697 {
698 }
699 ATF_TC_BODY(wmemset_heap_after_end, tc)
700 {
701 #define BUF __stack.__buf
702 	struct {
703 		uint8_t padding_l;
704 		wchar_t * __buf;
705 		uint8_t padding_r;
706 	} __stack;
707 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
708 	const size_t __len = 42 + 1;
709 	const size_t __idx __unused = __len - 1;
710 	pid_t __child;
711 	int __status;
712 
713 	__child = fork();
714 	ATF_REQUIRE(__child >= 0);
715 	if (__child > 0)
716 		goto monitor;
717 
718 	/* Child */
719 	disable_coredumps();
720 	__stack.__buf = malloc(__bufsz);
721 
722 	wmemset(__stack.__buf, L'0', __len);
723 	_exit(EX_SOFTWARE);	/* Should have aborted. */
724 
725 monitor:
726 	while (waitpid(__child, &__status, 0) != __child) {
727 		ATF_REQUIRE_EQ(EINTR, errno);
728 	}
729 
730 	if (!WIFSIGNALED(__status)) {
731 		switch (WEXITSTATUS(__status)) {
732 		case EX_SOFTWARE:
733 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
734 			break;
735 		case EX_OSERR:
736 			atf_tc_fail("setrlimit(2) failed");
737 			break;
738 		default:
739 			atf_tc_fail("child exited with status %d",
740 			    WEXITSTATUS(__status));
741 		}
742 	} else {
743 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
744 	}
745 #undef BUF
746 
747 }
748 
749 ATF_TC(wcpcpy_before_end);
750 ATF_TC_HEAD(wcpcpy_before_end, tc)
751 {
752 }
753 ATF_TC_BODY(wcpcpy_before_end, tc)
754 {
755 #define BUF &__stack.__buf
756 	struct {
757 		uint8_t padding_l;
758 		wchar_t __buf[42];
759 		uint8_t padding_r;
760 	} __stack;
761 	const size_t __bufsz __unused = sizeof(__stack.__buf);
762 	const size_t __len = 42 - 1;
763 	const size_t __idx __unused = __len - 1;
764 	wchar_t src[__len];
765 
766 	wmemset(__stack.__buf, 0, __len);
767 	wmemset(src, 'A', __len - 1);
768 	src[__len - 1] = '\0';
769 
770 	wcpcpy(__stack.__buf, src);
771 #undef BUF
772 
773 }
774 
775 ATF_TC(wcpcpy_end);
776 ATF_TC_HEAD(wcpcpy_end, tc)
777 {
778 }
779 ATF_TC_BODY(wcpcpy_end, tc)
780 {
781 #define BUF &__stack.__buf
782 	struct {
783 		uint8_t padding_l;
784 		wchar_t __buf[42];
785 		uint8_t padding_r;
786 	} __stack;
787 	const size_t __bufsz __unused = sizeof(__stack.__buf);
788 	const size_t __len = 42;
789 	const size_t __idx __unused = __len - 1;
790 	wchar_t src[__len];
791 
792 	wmemset(__stack.__buf, 0, __len);
793 	wmemset(src, 'A', __len - 1);
794 	src[__len - 1] = '\0';
795 
796 	wcpcpy(__stack.__buf, src);
797 #undef BUF
798 
799 }
800 
801 ATF_TC(wcpcpy_heap_before_end);
802 ATF_TC_HEAD(wcpcpy_heap_before_end, tc)
803 {
804 }
805 ATF_TC_BODY(wcpcpy_heap_before_end, tc)
806 {
807 #define BUF __stack.__buf
808 	struct {
809 		uint8_t padding_l;
810 		wchar_t * __buf;
811 		uint8_t padding_r;
812 	} __stack;
813 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
814 	const size_t __len = 42 - 1;
815 	const size_t __idx __unused = __len - 1;
816 	wchar_t src[__len];
817 
818 	__stack.__buf = malloc(__bufsz);
819 	wmemset(__stack.__buf, 0, __len);
820 	wmemset(src, 'A', __len - 1);
821 	src[__len - 1] = '\0';
822 
823 	wcpcpy(__stack.__buf, src);
824 #undef BUF
825 
826 }
827 
828 ATF_TC(wcpcpy_heap_end);
829 ATF_TC_HEAD(wcpcpy_heap_end, tc)
830 {
831 }
832 ATF_TC_BODY(wcpcpy_heap_end, tc)
833 {
834 #define BUF __stack.__buf
835 	struct {
836 		uint8_t padding_l;
837 		wchar_t * __buf;
838 		uint8_t padding_r;
839 	} __stack;
840 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
841 	const size_t __len = 42;
842 	const size_t __idx __unused = __len - 1;
843 	wchar_t src[__len];
844 
845 	__stack.__buf = malloc(__bufsz);
846 	wmemset(__stack.__buf, 0, __len);
847 	wmemset(src, 'A', __len - 1);
848 	src[__len - 1] = '\0';
849 
850 	wcpcpy(__stack.__buf, src);
851 #undef BUF
852 
853 }
854 
855 ATF_TC(wcpcpy_heap_after_end);
856 ATF_TC_HEAD(wcpcpy_heap_after_end, tc)
857 {
858 }
859 ATF_TC_BODY(wcpcpy_heap_after_end, tc)
860 {
861 #define BUF __stack.__buf
862 	struct {
863 		uint8_t padding_l;
864 		wchar_t * __buf;
865 		uint8_t padding_r;
866 	} __stack;
867 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
868 	const size_t __len = 42 + 1;
869 	const size_t __idx __unused = __len - 1;
870 	pid_t __child;
871 	int __status;
872 	wchar_t src[__len];
873 
874 	__child = fork();
875 	ATF_REQUIRE(__child >= 0);
876 	if (__child > 0)
877 		goto monitor;
878 
879 	/* Child */
880 	disable_coredumps();
881 	__stack.__buf = malloc(__bufsz);
882 	wmemset(__stack.__buf, 0, __len);
883 	wmemset(src, 'A', __len - 1);
884 	src[__len - 1] = '\0';
885 
886 	wcpcpy(__stack.__buf, src);
887 	_exit(EX_SOFTWARE);	/* Should have aborted. */
888 
889 monitor:
890 	while (waitpid(__child, &__status, 0) != __child) {
891 		ATF_REQUIRE_EQ(EINTR, errno);
892 	}
893 
894 	if (!WIFSIGNALED(__status)) {
895 		switch (WEXITSTATUS(__status)) {
896 		case EX_SOFTWARE:
897 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
898 			break;
899 		case EX_OSERR:
900 			atf_tc_fail("setrlimit(2) failed");
901 			break;
902 		default:
903 			atf_tc_fail("child exited with status %d",
904 			    WEXITSTATUS(__status));
905 		}
906 	} else {
907 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
908 	}
909 #undef BUF
910 
911 }
912 
913 ATF_TC(wcpncpy_before_end);
914 ATF_TC_HEAD(wcpncpy_before_end, tc)
915 {
916 }
917 ATF_TC_BODY(wcpncpy_before_end, tc)
918 {
919 #define BUF &__stack.__buf
920 	struct {
921 		uint8_t padding_l;
922 		wchar_t __buf[42];
923 		uint8_t padding_r;
924 	} __stack;
925 	const size_t __bufsz __unused = sizeof(__stack.__buf);
926 	const size_t __len = 42 - 1;
927 	const size_t __idx __unused = __len - 1;
928 	wchar_t src[__len];
929 
930 	wmemset(__stack.__buf, 0, __len);
931 	wmemset(src, 'A', __len - 1);
932 	src[__len - 1] = '\0';
933 
934 	wcpncpy(__stack.__buf, src, __len);
935 #undef BUF
936 
937 }
938 
939 ATF_TC(wcpncpy_end);
940 ATF_TC_HEAD(wcpncpy_end, tc)
941 {
942 }
943 ATF_TC_BODY(wcpncpy_end, tc)
944 {
945 #define BUF &__stack.__buf
946 	struct {
947 		uint8_t padding_l;
948 		wchar_t __buf[42];
949 		uint8_t padding_r;
950 	} __stack;
951 	const size_t __bufsz __unused = sizeof(__stack.__buf);
952 	const size_t __len = 42;
953 	const size_t __idx __unused = __len - 1;
954 	wchar_t src[__len];
955 
956 	wmemset(__stack.__buf, 0, __len);
957 	wmemset(src, 'A', __len - 1);
958 	src[__len - 1] = '\0';
959 
960 	wcpncpy(__stack.__buf, src, __len);
961 #undef BUF
962 
963 }
964 
965 ATF_TC(wcpncpy_heap_before_end);
966 ATF_TC_HEAD(wcpncpy_heap_before_end, tc)
967 {
968 }
969 ATF_TC_BODY(wcpncpy_heap_before_end, tc)
970 {
971 #define BUF __stack.__buf
972 	struct {
973 		uint8_t padding_l;
974 		wchar_t * __buf;
975 		uint8_t padding_r;
976 	} __stack;
977 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
978 	const size_t __len = 42 - 1;
979 	const size_t __idx __unused = __len - 1;
980 	wchar_t src[__len];
981 
982 	__stack.__buf = malloc(__bufsz);
983 	wmemset(__stack.__buf, 0, __len);
984 	wmemset(src, 'A', __len - 1);
985 	src[__len - 1] = '\0';
986 
987 	wcpncpy(__stack.__buf, src, __len);
988 #undef BUF
989 
990 }
991 
992 ATF_TC(wcpncpy_heap_end);
993 ATF_TC_HEAD(wcpncpy_heap_end, tc)
994 {
995 }
996 ATF_TC_BODY(wcpncpy_heap_end, tc)
997 {
998 #define BUF __stack.__buf
999 	struct {
1000 		uint8_t padding_l;
1001 		wchar_t * __buf;
1002 		uint8_t padding_r;
1003 	} __stack;
1004 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1005 	const size_t __len = 42;
1006 	const size_t __idx __unused = __len - 1;
1007 	wchar_t src[__len];
1008 
1009 	__stack.__buf = malloc(__bufsz);
1010 	wmemset(__stack.__buf, 0, __len);
1011 	wmemset(src, 'A', __len - 1);
1012 	src[__len - 1] = '\0';
1013 
1014 	wcpncpy(__stack.__buf, src, __len);
1015 #undef BUF
1016 
1017 }
1018 
1019 ATF_TC(wcpncpy_heap_after_end);
1020 ATF_TC_HEAD(wcpncpy_heap_after_end, tc)
1021 {
1022 }
1023 ATF_TC_BODY(wcpncpy_heap_after_end, tc)
1024 {
1025 #define BUF __stack.__buf
1026 	struct {
1027 		uint8_t padding_l;
1028 		wchar_t * __buf;
1029 		uint8_t padding_r;
1030 	} __stack;
1031 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1032 	const size_t __len = 42 + 1;
1033 	const size_t __idx __unused = __len - 1;
1034 	pid_t __child;
1035 	int __status;
1036 	wchar_t src[__len];
1037 
1038 	__child = fork();
1039 	ATF_REQUIRE(__child >= 0);
1040 	if (__child > 0)
1041 		goto monitor;
1042 
1043 	/* Child */
1044 	disable_coredumps();
1045 	__stack.__buf = malloc(__bufsz);
1046 	wmemset(__stack.__buf, 0, __len);
1047 	wmemset(src, 'A', __len - 1);
1048 	src[__len - 1] = '\0';
1049 
1050 	wcpncpy(__stack.__buf, src, __len);
1051 	_exit(EX_SOFTWARE);	/* Should have aborted. */
1052 
1053 monitor:
1054 	while (waitpid(__child, &__status, 0) != __child) {
1055 		ATF_REQUIRE_EQ(EINTR, errno);
1056 	}
1057 
1058 	if (!WIFSIGNALED(__status)) {
1059 		switch (WEXITSTATUS(__status)) {
1060 		case EX_SOFTWARE:
1061 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
1062 			break;
1063 		case EX_OSERR:
1064 			atf_tc_fail("setrlimit(2) failed");
1065 			break;
1066 		default:
1067 			atf_tc_fail("child exited with status %d",
1068 			    WEXITSTATUS(__status));
1069 		}
1070 	} else {
1071 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
1072 	}
1073 #undef BUF
1074 
1075 }
1076 
1077 ATF_TC(wcscat_before_end);
1078 ATF_TC_HEAD(wcscat_before_end, tc)
1079 {
1080 }
1081 ATF_TC_BODY(wcscat_before_end, tc)
1082 {
1083 #define BUF &__stack.__buf
1084 	struct {
1085 		uint8_t padding_l;
1086 		wchar_t __buf[42];
1087 		uint8_t padding_r;
1088 	} __stack;
1089 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1090 	const size_t __len = 42 - 1;
1091 	const size_t __idx __unused = __len - 1;
1092 	wchar_t src[__len];
1093 
1094 	wmemset(__stack.__buf, 0, __len);
1095 	wmemset(src, 'A', __len - 1);
1096 	src[__len - 1] = '\0';
1097 
1098 	wcscat(__stack.__buf, src);
1099 #undef BUF
1100 
1101 }
1102 
1103 ATF_TC(wcscat_end);
1104 ATF_TC_HEAD(wcscat_end, tc)
1105 {
1106 }
1107 ATF_TC_BODY(wcscat_end, tc)
1108 {
1109 #define BUF &__stack.__buf
1110 	struct {
1111 		uint8_t padding_l;
1112 		wchar_t __buf[42];
1113 		uint8_t padding_r;
1114 	} __stack;
1115 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1116 	const size_t __len = 42;
1117 	const size_t __idx __unused = __len - 1;
1118 	wchar_t src[__len];
1119 
1120 	wmemset(__stack.__buf, 0, __len);
1121 	wmemset(src, 'A', __len - 1);
1122 	src[__len - 1] = '\0';
1123 
1124 	wcscat(__stack.__buf, src);
1125 #undef BUF
1126 
1127 }
1128 
1129 ATF_TC(wcscat_heap_before_end);
1130 ATF_TC_HEAD(wcscat_heap_before_end, tc)
1131 {
1132 }
1133 ATF_TC_BODY(wcscat_heap_before_end, tc)
1134 {
1135 #define BUF __stack.__buf
1136 	struct {
1137 		uint8_t padding_l;
1138 		wchar_t * __buf;
1139 		uint8_t padding_r;
1140 	} __stack;
1141 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1142 	const size_t __len = 42 - 1;
1143 	const size_t __idx __unused = __len - 1;
1144 	wchar_t src[__len];
1145 
1146 	__stack.__buf = malloc(__bufsz);
1147 	wmemset(__stack.__buf, 0, __len);
1148 	wmemset(src, 'A', __len - 1);
1149 	src[__len - 1] = '\0';
1150 
1151 	wcscat(__stack.__buf, src);
1152 #undef BUF
1153 
1154 }
1155 
1156 ATF_TC(wcscat_heap_end);
1157 ATF_TC_HEAD(wcscat_heap_end, tc)
1158 {
1159 }
1160 ATF_TC_BODY(wcscat_heap_end, tc)
1161 {
1162 #define BUF __stack.__buf
1163 	struct {
1164 		uint8_t padding_l;
1165 		wchar_t * __buf;
1166 		uint8_t padding_r;
1167 	} __stack;
1168 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1169 	const size_t __len = 42;
1170 	const size_t __idx __unused = __len - 1;
1171 	wchar_t src[__len];
1172 
1173 	__stack.__buf = malloc(__bufsz);
1174 	wmemset(__stack.__buf, 0, __len);
1175 	wmemset(src, 'A', __len - 1);
1176 	src[__len - 1] = '\0';
1177 
1178 	wcscat(__stack.__buf, src);
1179 #undef BUF
1180 
1181 }
1182 
1183 ATF_TC(wcscat_heap_after_end);
1184 ATF_TC_HEAD(wcscat_heap_after_end, tc)
1185 {
1186 }
1187 ATF_TC_BODY(wcscat_heap_after_end, tc)
1188 {
1189 #define BUF __stack.__buf
1190 	struct {
1191 		uint8_t padding_l;
1192 		wchar_t * __buf;
1193 		uint8_t padding_r;
1194 	} __stack;
1195 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1196 	const size_t __len = 42 + 1;
1197 	const size_t __idx __unused = __len - 1;
1198 	pid_t __child;
1199 	int __status;
1200 	wchar_t src[__len];
1201 
1202 	__child = fork();
1203 	ATF_REQUIRE(__child >= 0);
1204 	if (__child > 0)
1205 		goto monitor;
1206 
1207 	/* Child */
1208 	disable_coredumps();
1209 	__stack.__buf = malloc(__bufsz);
1210 	wmemset(__stack.__buf, 0, __len);
1211 	wmemset(src, 'A', __len - 1);
1212 	src[__len - 1] = '\0';
1213 
1214 	wcscat(__stack.__buf, src);
1215 	_exit(EX_SOFTWARE);	/* Should have aborted. */
1216 
1217 monitor:
1218 	while (waitpid(__child, &__status, 0) != __child) {
1219 		ATF_REQUIRE_EQ(EINTR, errno);
1220 	}
1221 
1222 	if (!WIFSIGNALED(__status)) {
1223 		switch (WEXITSTATUS(__status)) {
1224 		case EX_SOFTWARE:
1225 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
1226 			break;
1227 		case EX_OSERR:
1228 			atf_tc_fail("setrlimit(2) failed");
1229 			break;
1230 		default:
1231 			atf_tc_fail("child exited with status %d",
1232 			    WEXITSTATUS(__status));
1233 		}
1234 	} else {
1235 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
1236 	}
1237 #undef BUF
1238 
1239 }
1240 
1241 ATF_TC(wcslcat_before_end);
1242 ATF_TC_HEAD(wcslcat_before_end, tc)
1243 {
1244 }
1245 ATF_TC_BODY(wcslcat_before_end, tc)
1246 {
1247 #define BUF &__stack.__buf
1248 	struct {
1249 		uint8_t padding_l;
1250 		wchar_t __buf[42];
1251 		uint8_t padding_r;
1252 	} __stack;
1253 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1254 	const size_t __len = 42 - 1;
1255 	const size_t __idx __unused = __len - 1;
1256 	wchar_t src[__len];
1257 
1258 	wmemset(__stack.__buf, 0, __len);
1259 	wmemset(src, 'A', __len - 1);
1260 	src[__len - 1] = '\0';
1261 
1262 	wcslcat(__stack.__buf, src, __len);
1263 #undef BUF
1264 
1265 }
1266 
1267 ATF_TC(wcslcat_end);
1268 ATF_TC_HEAD(wcslcat_end, tc)
1269 {
1270 }
1271 ATF_TC_BODY(wcslcat_end, tc)
1272 {
1273 #define BUF &__stack.__buf
1274 	struct {
1275 		uint8_t padding_l;
1276 		wchar_t __buf[42];
1277 		uint8_t padding_r;
1278 	} __stack;
1279 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1280 	const size_t __len = 42;
1281 	const size_t __idx __unused = __len - 1;
1282 	wchar_t src[__len];
1283 
1284 	wmemset(__stack.__buf, 0, __len);
1285 	wmemset(src, 'A', __len - 1);
1286 	src[__len - 1] = '\0';
1287 
1288 	wcslcat(__stack.__buf, src, __len);
1289 #undef BUF
1290 
1291 }
1292 
1293 ATF_TC(wcslcat_heap_before_end);
1294 ATF_TC_HEAD(wcslcat_heap_before_end, tc)
1295 {
1296 }
1297 ATF_TC_BODY(wcslcat_heap_before_end, tc)
1298 {
1299 #define BUF __stack.__buf
1300 	struct {
1301 		uint8_t padding_l;
1302 		wchar_t * __buf;
1303 		uint8_t padding_r;
1304 	} __stack;
1305 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1306 	const size_t __len = 42 - 1;
1307 	const size_t __idx __unused = __len - 1;
1308 	wchar_t src[__len];
1309 
1310 	__stack.__buf = malloc(__bufsz);
1311 	wmemset(__stack.__buf, 0, __len);
1312 	wmemset(src, 'A', __len - 1);
1313 	src[__len - 1] = '\0';
1314 
1315 	wcslcat(__stack.__buf, src, __len);
1316 #undef BUF
1317 
1318 }
1319 
1320 ATF_TC(wcslcat_heap_end);
1321 ATF_TC_HEAD(wcslcat_heap_end, tc)
1322 {
1323 }
1324 ATF_TC_BODY(wcslcat_heap_end, tc)
1325 {
1326 #define BUF __stack.__buf
1327 	struct {
1328 		uint8_t padding_l;
1329 		wchar_t * __buf;
1330 		uint8_t padding_r;
1331 	} __stack;
1332 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1333 	const size_t __len = 42;
1334 	const size_t __idx __unused = __len - 1;
1335 	wchar_t src[__len];
1336 
1337 	__stack.__buf = malloc(__bufsz);
1338 	wmemset(__stack.__buf, 0, __len);
1339 	wmemset(src, 'A', __len - 1);
1340 	src[__len - 1] = '\0';
1341 
1342 	wcslcat(__stack.__buf, src, __len);
1343 #undef BUF
1344 
1345 }
1346 
1347 ATF_TC(wcslcat_heap_after_end);
1348 ATF_TC_HEAD(wcslcat_heap_after_end, tc)
1349 {
1350 }
1351 ATF_TC_BODY(wcslcat_heap_after_end, tc)
1352 {
1353 #define BUF __stack.__buf
1354 	struct {
1355 		uint8_t padding_l;
1356 		wchar_t * __buf;
1357 		uint8_t padding_r;
1358 	} __stack;
1359 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1360 	const size_t __len = 42 + 1;
1361 	const size_t __idx __unused = __len - 1;
1362 	pid_t __child;
1363 	int __status;
1364 	wchar_t src[__len];
1365 
1366 	__child = fork();
1367 	ATF_REQUIRE(__child >= 0);
1368 	if (__child > 0)
1369 		goto monitor;
1370 
1371 	/* Child */
1372 	disable_coredumps();
1373 	__stack.__buf = malloc(__bufsz);
1374 	wmemset(__stack.__buf, 0, __len);
1375 	wmemset(src, 'A', __len - 1);
1376 	src[__len - 1] = '\0';
1377 
1378 	wcslcat(__stack.__buf, src, __len);
1379 	_exit(EX_SOFTWARE);	/* Should have aborted. */
1380 
1381 monitor:
1382 	while (waitpid(__child, &__status, 0) != __child) {
1383 		ATF_REQUIRE_EQ(EINTR, errno);
1384 	}
1385 
1386 	if (!WIFSIGNALED(__status)) {
1387 		switch (WEXITSTATUS(__status)) {
1388 		case EX_SOFTWARE:
1389 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
1390 			break;
1391 		case EX_OSERR:
1392 			atf_tc_fail("setrlimit(2) failed");
1393 			break;
1394 		default:
1395 			atf_tc_fail("child exited with status %d",
1396 			    WEXITSTATUS(__status));
1397 		}
1398 	} else {
1399 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
1400 	}
1401 #undef BUF
1402 
1403 }
1404 
1405 ATF_TC(wcsncat_before_end);
1406 ATF_TC_HEAD(wcsncat_before_end, tc)
1407 {
1408 }
1409 ATF_TC_BODY(wcsncat_before_end, tc)
1410 {
1411 #define BUF &__stack.__buf
1412 	struct {
1413 		uint8_t padding_l;
1414 		wchar_t __buf[42];
1415 		uint8_t padding_r;
1416 	} __stack;
1417 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1418 	const size_t __len = 42 - 1;
1419 	const size_t __idx __unused = __len - 1;
1420 	wchar_t src[__len];
1421 
1422 	wmemset(__stack.__buf, 0, __len);
1423 	wmemset(src, 'A', __len - 1);
1424 	src[__len - 1] = '\0';
1425 
1426 	wcsncat(__stack.__buf, src, __len);
1427 #undef BUF
1428 
1429 }
1430 
1431 ATF_TC(wcsncat_end);
1432 ATF_TC_HEAD(wcsncat_end, tc)
1433 {
1434 }
1435 ATF_TC_BODY(wcsncat_end, tc)
1436 {
1437 #define BUF &__stack.__buf
1438 	struct {
1439 		uint8_t padding_l;
1440 		wchar_t __buf[42];
1441 		uint8_t padding_r;
1442 	} __stack;
1443 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1444 	const size_t __len = 42;
1445 	const size_t __idx __unused = __len - 1;
1446 	wchar_t src[__len];
1447 
1448 	wmemset(__stack.__buf, 0, __len);
1449 	wmemset(src, 'A', __len - 1);
1450 	src[__len - 1] = '\0';
1451 
1452 	wcsncat(__stack.__buf, src, __len);
1453 #undef BUF
1454 
1455 }
1456 
1457 ATF_TC(wcsncat_heap_before_end);
1458 ATF_TC_HEAD(wcsncat_heap_before_end, tc)
1459 {
1460 }
1461 ATF_TC_BODY(wcsncat_heap_before_end, tc)
1462 {
1463 #define BUF __stack.__buf
1464 	struct {
1465 		uint8_t padding_l;
1466 		wchar_t * __buf;
1467 		uint8_t padding_r;
1468 	} __stack;
1469 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1470 	const size_t __len = 42 - 1;
1471 	const size_t __idx __unused = __len - 1;
1472 	wchar_t src[__len];
1473 
1474 	__stack.__buf = malloc(__bufsz);
1475 	wmemset(__stack.__buf, 0, __len);
1476 	wmemset(src, 'A', __len - 1);
1477 	src[__len - 1] = '\0';
1478 
1479 	wcsncat(__stack.__buf, src, __len);
1480 #undef BUF
1481 
1482 }
1483 
1484 ATF_TC(wcsncat_heap_end);
1485 ATF_TC_HEAD(wcsncat_heap_end, tc)
1486 {
1487 }
1488 ATF_TC_BODY(wcsncat_heap_end, tc)
1489 {
1490 #define BUF __stack.__buf
1491 	struct {
1492 		uint8_t padding_l;
1493 		wchar_t * __buf;
1494 		uint8_t padding_r;
1495 	} __stack;
1496 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1497 	const size_t __len = 42;
1498 	const size_t __idx __unused = __len - 1;
1499 	wchar_t src[__len];
1500 
1501 	__stack.__buf = malloc(__bufsz);
1502 	wmemset(__stack.__buf, 0, __len);
1503 	wmemset(src, 'A', __len - 1);
1504 	src[__len - 1] = '\0';
1505 
1506 	wcsncat(__stack.__buf, src, __len);
1507 #undef BUF
1508 
1509 }
1510 
1511 ATF_TC(wcsncat_heap_after_end);
1512 ATF_TC_HEAD(wcsncat_heap_after_end, tc)
1513 {
1514 }
1515 ATF_TC_BODY(wcsncat_heap_after_end, tc)
1516 {
1517 #define BUF __stack.__buf
1518 	struct {
1519 		uint8_t padding_l;
1520 		wchar_t * __buf;
1521 		uint8_t padding_r;
1522 	} __stack;
1523 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1524 	const size_t __len = 42 + 1;
1525 	const size_t __idx __unused = __len - 1;
1526 	pid_t __child;
1527 	int __status;
1528 	wchar_t src[__len];
1529 
1530 	__child = fork();
1531 	ATF_REQUIRE(__child >= 0);
1532 	if (__child > 0)
1533 		goto monitor;
1534 
1535 	/* Child */
1536 	disable_coredumps();
1537 	__stack.__buf = malloc(__bufsz);
1538 	wmemset(__stack.__buf, 0, __len);
1539 	wmemset(src, 'A', __len - 1);
1540 	src[__len - 1] = '\0';
1541 
1542 	wcsncat(__stack.__buf, src, __len);
1543 	_exit(EX_SOFTWARE);	/* Should have aborted. */
1544 
1545 monitor:
1546 	while (waitpid(__child, &__status, 0) != __child) {
1547 		ATF_REQUIRE_EQ(EINTR, errno);
1548 	}
1549 
1550 	if (!WIFSIGNALED(__status)) {
1551 		switch (WEXITSTATUS(__status)) {
1552 		case EX_SOFTWARE:
1553 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
1554 			break;
1555 		case EX_OSERR:
1556 			atf_tc_fail("setrlimit(2) failed");
1557 			break;
1558 		default:
1559 			atf_tc_fail("child exited with status %d",
1560 			    WEXITSTATUS(__status));
1561 		}
1562 	} else {
1563 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
1564 	}
1565 #undef BUF
1566 
1567 }
1568 
1569 ATF_TC(wcscpy_before_end);
1570 ATF_TC_HEAD(wcscpy_before_end, tc)
1571 {
1572 }
1573 ATF_TC_BODY(wcscpy_before_end, tc)
1574 {
1575 #define BUF &__stack.__buf
1576 	struct {
1577 		uint8_t padding_l;
1578 		wchar_t __buf[42];
1579 		uint8_t padding_r;
1580 	} __stack;
1581 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1582 	const size_t __len = 42 - 1;
1583 	const size_t __idx __unused = __len - 1;
1584 	wchar_t src[__len];
1585 
1586 	wmemset(__stack.__buf, 0, __len);
1587 	wmemset(src, 'A', __len - 1);
1588 	src[__len - 1] = '\0';
1589 
1590 	wcscpy(__stack.__buf, src);
1591 #undef BUF
1592 
1593 }
1594 
1595 ATF_TC(wcscpy_end);
1596 ATF_TC_HEAD(wcscpy_end, tc)
1597 {
1598 }
1599 ATF_TC_BODY(wcscpy_end, tc)
1600 {
1601 #define BUF &__stack.__buf
1602 	struct {
1603 		uint8_t padding_l;
1604 		wchar_t __buf[42];
1605 		uint8_t padding_r;
1606 	} __stack;
1607 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1608 	const size_t __len = 42;
1609 	const size_t __idx __unused = __len - 1;
1610 	wchar_t src[__len];
1611 
1612 	wmemset(__stack.__buf, 0, __len);
1613 	wmemset(src, 'A', __len - 1);
1614 	src[__len - 1] = '\0';
1615 
1616 	wcscpy(__stack.__buf, src);
1617 #undef BUF
1618 
1619 }
1620 
1621 ATF_TC(wcscpy_heap_before_end);
1622 ATF_TC_HEAD(wcscpy_heap_before_end, tc)
1623 {
1624 }
1625 ATF_TC_BODY(wcscpy_heap_before_end, tc)
1626 {
1627 #define BUF __stack.__buf
1628 	struct {
1629 		uint8_t padding_l;
1630 		wchar_t * __buf;
1631 		uint8_t padding_r;
1632 	} __stack;
1633 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1634 	const size_t __len = 42 - 1;
1635 	const size_t __idx __unused = __len - 1;
1636 	wchar_t src[__len];
1637 
1638 	__stack.__buf = malloc(__bufsz);
1639 	wmemset(__stack.__buf, 0, __len);
1640 	wmemset(src, 'A', __len - 1);
1641 	src[__len - 1] = '\0';
1642 
1643 	wcscpy(__stack.__buf, src);
1644 #undef BUF
1645 
1646 }
1647 
1648 ATF_TC(wcscpy_heap_end);
1649 ATF_TC_HEAD(wcscpy_heap_end, tc)
1650 {
1651 }
1652 ATF_TC_BODY(wcscpy_heap_end, tc)
1653 {
1654 #define BUF __stack.__buf
1655 	struct {
1656 		uint8_t padding_l;
1657 		wchar_t * __buf;
1658 		uint8_t padding_r;
1659 	} __stack;
1660 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1661 	const size_t __len = 42;
1662 	const size_t __idx __unused = __len - 1;
1663 	wchar_t src[__len];
1664 
1665 	__stack.__buf = malloc(__bufsz);
1666 	wmemset(__stack.__buf, 0, __len);
1667 	wmemset(src, 'A', __len - 1);
1668 	src[__len - 1] = '\0';
1669 
1670 	wcscpy(__stack.__buf, src);
1671 #undef BUF
1672 
1673 }
1674 
1675 ATF_TC(wcscpy_heap_after_end);
1676 ATF_TC_HEAD(wcscpy_heap_after_end, tc)
1677 {
1678 }
1679 ATF_TC_BODY(wcscpy_heap_after_end, tc)
1680 {
1681 #define BUF __stack.__buf
1682 	struct {
1683 		uint8_t padding_l;
1684 		wchar_t * __buf;
1685 		uint8_t padding_r;
1686 	} __stack;
1687 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1688 	const size_t __len = 42 + 1;
1689 	const size_t __idx __unused = __len - 1;
1690 	pid_t __child;
1691 	int __status;
1692 	wchar_t src[__len];
1693 
1694 	__child = fork();
1695 	ATF_REQUIRE(__child >= 0);
1696 	if (__child > 0)
1697 		goto monitor;
1698 
1699 	/* Child */
1700 	disable_coredumps();
1701 	__stack.__buf = malloc(__bufsz);
1702 	wmemset(__stack.__buf, 0, __len);
1703 	wmemset(src, 'A', __len - 1);
1704 	src[__len - 1] = '\0';
1705 
1706 	wcscpy(__stack.__buf, src);
1707 	_exit(EX_SOFTWARE);	/* Should have aborted. */
1708 
1709 monitor:
1710 	while (waitpid(__child, &__status, 0) != __child) {
1711 		ATF_REQUIRE_EQ(EINTR, errno);
1712 	}
1713 
1714 	if (!WIFSIGNALED(__status)) {
1715 		switch (WEXITSTATUS(__status)) {
1716 		case EX_SOFTWARE:
1717 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
1718 			break;
1719 		case EX_OSERR:
1720 			atf_tc_fail("setrlimit(2) failed");
1721 			break;
1722 		default:
1723 			atf_tc_fail("child exited with status %d",
1724 			    WEXITSTATUS(__status));
1725 		}
1726 	} else {
1727 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
1728 	}
1729 #undef BUF
1730 
1731 }
1732 
1733 ATF_TC(wcslcpy_before_end);
1734 ATF_TC_HEAD(wcslcpy_before_end, tc)
1735 {
1736 }
1737 ATF_TC_BODY(wcslcpy_before_end, tc)
1738 {
1739 #define BUF &__stack.__buf
1740 	struct {
1741 		uint8_t padding_l;
1742 		wchar_t __buf[42];
1743 		uint8_t padding_r;
1744 	} __stack;
1745 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1746 	const size_t __len = 42 - 1;
1747 	const size_t __idx __unused = __len - 1;
1748 	wchar_t src[__len];
1749 
1750 	wmemset(__stack.__buf, 0, __len);
1751 	wmemset(src, 'A', __len - 1);
1752 	src[__len - 1] = '\0';
1753 
1754 	wcslcpy(__stack.__buf, src, __len);
1755 #undef BUF
1756 
1757 }
1758 
1759 ATF_TC(wcslcpy_end);
1760 ATF_TC_HEAD(wcslcpy_end, tc)
1761 {
1762 }
1763 ATF_TC_BODY(wcslcpy_end, tc)
1764 {
1765 #define BUF &__stack.__buf
1766 	struct {
1767 		uint8_t padding_l;
1768 		wchar_t __buf[42];
1769 		uint8_t padding_r;
1770 	} __stack;
1771 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1772 	const size_t __len = 42;
1773 	const size_t __idx __unused = __len - 1;
1774 	wchar_t src[__len];
1775 
1776 	wmemset(__stack.__buf, 0, __len);
1777 	wmemset(src, 'A', __len - 1);
1778 	src[__len - 1] = '\0';
1779 
1780 	wcslcpy(__stack.__buf, src, __len);
1781 #undef BUF
1782 
1783 }
1784 
1785 ATF_TC(wcslcpy_heap_before_end);
1786 ATF_TC_HEAD(wcslcpy_heap_before_end, tc)
1787 {
1788 }
1789 ATF_TC_BODY(wcslcpy_heap_before_end, tc)
1790 {
1791 #define BUF __stack.__buf
1792 	struct {
1793 		uint8_t padding_l;
1794 		wchar_t * __buf;
1795 		uint8_t padding_r;
1796 	} __stack;
1797 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1798 	const size_t __len = 42 - 1;
1799 	const size_t __idx __unused = __len - 1;
1800 	wchar_t src[__len];
1801 
1802 	__stack.__buf = malloc(__bufsz);
1803 	wmemset(__stack.__buf, 0, __len);
1804 	wmemset(src, 'A', __len - 1);
1805 	src[__len - 1] = '\0';
1806 
1807 	wcslcpy(__stack.__buf, src, __len);
1808 #undef BUF
1809 
1810 }
1811 
1812 ATF_TC(wcslcpy_heap_end);
1813 ATF_TC_HEAD(wcslcpy_heap_end, tc)
1814 {
1815 }
1816 ATF_TC_BODY(wcslcpy_heap_end, tc)
1817 {
1818 #define BUF __stack.__buf
1819 	struct {
1820 		uint8_t padding_l;
1821 		wchar_t * __buf;
1822 		uint8_t padding_r;
1823 	} __stack;
1824 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1825 	const size_t __len = 42;
1826 	const size_t __idx __unused = __len - 1;
1827 	wchar_t src[__len];
1828 
1829 	__stack.__buf = malloc(__bufsz);
1830 	wmemset(__stack.__buf, 0, __len);
1831 	wmemset(src, 'A', __len - 1);
1832 	src[__len - 1] = '\0';
1833 
1834 	wcslcpy(__stack.__buf, src, __len);
1835 #undef BUF
1836 
1837 }
1838 
1839 ATF_TC(wcslcpy_heap_after_end);
1840 ATF_TC_HEAD(wcslcpy_heap_after_end, tc)
1841 {
1842 }
1843 ATF_TC_BODY(wcslcpy_heap_after_end, tc)
1844 {
1845 #define BUF __stack.__buf
1846 	struct {
1847 		uint8_t padding_l;
1848 		wchar_t * __buf;
1849 		uint8_t padding_r;
1850 	} __stack;
1851 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1852 	const size_t __len = 42 + 1;
1853 	const size_t __idx __unused = __len - 1;
1854 	pid_t __child;
1855 	int __status;
1856 	wchar_t src[__len];
1857 
1858 	__child = fork();
1859 	ATF_REQUIRE(__child >= 0);
1860 	if (__child > 0)
1861 		goto monitor;
1862 
1863 	/* Child */
1864 	disable_coredumps();
1865 	__stack.__buf = malloc(__bufsz);
1866 	wmemset(__stack.__buf, 0, __len);
1867 	wmemset(src, 'A', __len - 1);
1868 	src[__len - 1] = '\0';
1869 
1870 	wcslcpy(__stack.__buf, src, __len);
1871 	_exit(EX_SOFTWARE);	/* Should have aborted. */
1872 
1873 monitor:
1874 	while (waitpid(__child, &__status, 0) != __child) {
1875 		ATF_REQUIRE_EQ(EINTR, errno);
1876 	}
1877 
1878 	if (!WIFSIGNALED(__status)) {
1879 		switch (WEXITSTATUS(__status)) {
1880 		case EX_SOFTWARE:
1881 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
1882 			break;
1883 		case EX_OSERR:
1884 			atf_tc_fail("setrlimit(2) failed");
1885 			break;
1886 		default:
1887 			atf_tc_fail("child exited with status %d",
1888 			    WEXITSTATUS(__status));
1889 		}
1890 	} else {
1891 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
1892 	}
1893 #undef BUF
1894 
1895 }
1896 
1897 ATF_TC(wcsncpy_before_end);
1898 ATF_TC_HEAD(wcsncpy_before_end, tc)
1899 {
1900 }
1901 ATF_TC_BODY(wcsncpy_before_end, tc)
1902 {
1903 #define BUF &__stack.__buf
1904 	struct {
1905 		uint8_t padding_l;
1906 		wchar_t __buf[42];
1907 		uint8_t padding_r;
1908 	} __stack;
1909 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1910 	const size_t __len = 42 - 1;
1911 	const size_t __idx __unused = __len - 1;
1912 	wchar_t src[__len];
1913 
1914 	wmemset(__stack.__buf, 0, __len);
1915 	wmemset(src, 'A', __len - 1);
1916 	src[__len - 1] = '\0';
1917 
1918 	wcsncpy(__stack.__buf, src, __len);
1919 #undef BUF
1920 
1921 }
1922 
1923 ATF_TC(wcsncpy_end);
1924 ATF_TC_HEAD(wcsncpy_end, tc)
1925 {
1926 }
1927 ATF_TC_BODY(wcsncpy_end, tc)
1928 {
1929 #define BUF &__stack.__buf
1930 	struct {
1931 		uint8_t padding_l;
1932 		wchar_t __buf[42];
1933 		uint8_t padding_r;
1934 	} __stack;
1935 	const size_t __bufsz __unused = sizeof(__stack.__buf);
1936 	const size_t __len = 42;
1937 	const size_t __idx __unused = __len - 1;
1938 	wchar_t src[__len];
1939 
1940 	wmemset(__stack.__buf, 0, __len);
1941 	wmemset(src, 'A', __len - 1);
1942 	src[__len - 1] = '\0';
1943 
1944 	wcsncpy(__stack.__buf, src, __len);
1945 #undef BUF
1946 
1947 }
1948 
1949 ATF_TC(wcsncpy_heap_before_end);
1950 ATF_TC_HEAD(wcsncpy_heap_before_end, tc)
1951 {
1952 }
1953 ATF_TC_BODY(wcsncpy_heap_before_end, tc)
1954 {
1955 #define BUF __stack.__buf
1956 	struct {
1957 		uint8_t padding_l;
1958 		wchar_t * __buf;
1959 		uint8_t padding_r;
1960 	} __stack;
1961 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1962 	const size_t __len = 42 - 1;
1963 	const size_t __idx __unused = __len - 1;
1964 	wchar_t src[__len];
1965 
1966 	__stack.__buf = malloc(__bufsz);
1967 	wmemset(__stack.__buf, 0, __len);
1968 	wmemset(src, 'A', __len - 1);
1969 	src[__len - 1] = '\0';
1970 
1971 	wcsncpy(__stack.__buf, src, __len);
1972 #undef BUF
1973 
1974 }
1975 
1976 ATF_TC(wcsncpy_heap_end);
1977 ATF_TC_HEAD(wcsncpy_heap_end, tc)
1978 {
1979 }
1980 ATF_TC_BODY(wcsncpy_heap_end, tc)
1981 {
1982 #define BUF __stack.__buf
1983 	struct {
1984 		uint8_t padding_l;
1985 		wchar_t * __buf;
1986 		uint8_t padding_r;
1987 	} __stack;
1988 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
1989 	const size_t __len = 42;
1990 	const size_t __idx __unused = __len - 1;
1991 	wchar_t src[__len];
1992 
1993 	__stack.__buf = malloc(__bufsz);
1994 	wmemset(__stack.__buf, 0, __len);
1995 	wmemset(src, 'A', __len - 1);
1996 	src[__len - 1] = '\0';
1997 
1998 	wcsncpy(__stack.__buf, src, __len);
1999 #undef BUF
2000 
2001 }
2002 
2003 ATF_TC(wcsncpy_heap_after_end);
2004 ATF_TC_HEAD(wcsncpy_heap_after_end, tc)
2005 {
2006 }
2007 ATF_TC_BODY(wcsncpy_heap_after_end, tc)
2008 {
2009 #define BUF __stack.__buf
2010 	struct {
2011 		uint8_t padding_l;
2012 		wchar_t * __buf;
2013 		uint8_t padding_r;
2014 	} __stack;
2015 	const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
2016 	const size_t __len = 42 + 1;
2017 	const size_t __idx __unused = __len - 1;
2018 	pid_t __child;
2019 	int __status;
2020 	wchar_t src[__len];
2021 
2022 	__child = fork();
2023 	ATF_REQUIRE(__child >= 0);
2024 	if (__child > 0)
2025 		goto monitor;
2026 
2027 	/* Child */
2028 	disable_coredumps();
2029 	__stack.__buf = malloc(__bufsz);
2030 	wmemset(__stack.__buf, 0, __len);
2031 	wmemset(src, 'A', __len - 1);
2032 	src[__len - 1] = '\0';
2033 
2034 	wcsncpy(__stack.__buf, src, __len);
2035 	_exit(EX_SOFTWARE);	/* Should have aborted. */
2036 
2037 monitor:
2038 	while (waitpid(__child, &__status, 0) != __child) {
2039 		ATF_REQUIRE_EQ(EINTR, errno);
2040 	}
2041 
2042 	if (!WIFSIGNALED(__status)) {
2043 		switch (WEXITSTATUS(__status)) {
2044 		case EX_SOFTWARE:
2045 			atf_tc_fail("FORTIFY_SOURCE failed to abort");
2046 			break;
2047 		case EX_OSERR:
2048 			atf_tc_fail("setrlimit(2) failed");
2049 			break;
2050 		default:
2051 			atf_tc_fail("child exited with status %d",
2052 			    WEXITSTATUS(__status));
2053 		}
2054 	} else {
2055 		ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
2056 	}
2057 #undef BUF
2058 
2059 }
2060 
2061 ATF_TP_ADD_TCS(tp)
2062 {
2063 	ATF_TP_ADD_TC(tp, wmemcpy_before_end);
2064 	ATF_TP_ADD_TC(tp, wmemcpy_end);
2065 	ATF_TP_ADD_TC(tp, wmemcpy_heap_before_end);
2066 	ATF_TP_ADD_TC(tp, wmemcpy_heap_end);
2067 	ATF_TP_ADD_TC(tp, wmemcpy_heap_after_end);
2068 	ATF_TP_ADD_TC(tp, wmempcpy_before_end);
2069 	ATF_TP_ADD_TC(tp, wmempcpy_end);
2070 	ATF_TP_ADD_TC(tp, wmempcpy_heap_before_end);
2071 	ATF_TP_ADD_TC(tp, wmempcpy_heap_end);
2072 	ATF_TP_ADD_TC(tp, wmempcpy_heap_after_end);
2073 	ATF_TP_ADD_TC(tp, wmemmove_before_end);
2074 	ATF_TP_ADD_TC(tp, wmemmove_end);
2075 	ATF_TP_ADD_TC(tp, wmemmove_heap_before_end);
2076 	ATF_TP_ADD_TC(tp, wmemmove_heap_end);
2077 	ATF_TP_ADD_TC(tp, wmemmove_heap_after_end);
2078 	ATF_TP_ADD_TC(tp, wmemset_before_end);
2079 	ATF_TP_ADD_TC(tp, wmemset_end);
2080 	ATF_TP_ADD_TC(tp, wmemset_heap_before_end);
2081 	ATF_TP_ADD_TC(tp, wmemset_heap_end);
2082 	ATF_TP_ADD_TC(tp, wmemset_heap_after_end);
2083 	ATF_TP_ADD_TC(tp, wcpcpy_before_end);
2084 	ATF_TP_ADD_TC(tp, wcpcpy_end);
2085 	ATF_TP_ADD_TC(tp, wcpcpy_heap_before_end);
2086 	ATF_TP_ADD_TC(tp, wcpcpy_heap_end);
2087 	ATF_TP_ADD_TC(tp, wcpcpy_heap_after_end);
2088 	ATF_TP_ADD_TC(tp, wcpncpy_before_end);
2089 	ATF_TP_ADD_TC(tp, wcpncpy_end);
2090 	ATF_TP_ADD_TC(tp, wcpncpy_heap_before_end);
2091 	ATF_TP_ADD_TC(tp, wcpncpy_heap_end);
2092 	ATF_TP_ADD_TC(tp, wcpncpy_heap_after_end);
2093 	ATF_TP_ADD_TC(tp, wcscat_before_end);
2094 	ATF_TP_ADD_TC(tp, wcscat_end);
2095 	ATF_TP_ADD_TC(tp, wcscat_heap_before_end);
2096 	ATF_TP_ADD_TC(tp, wcscat_heap_end);
2097 	ATF_TP_ADD_TC(tp, wcscat_heap_after_end);
2098 	ATF_TP_ADD_TC(tp, wcslcat_before_end);
2099 	ATF_TP_ADD_TC(tp, wcslcat_end);
2100 	ATF_TP_ADD_TC(tp, wcslcat_heap_before_end);
2101 	ATF_TP_ADD_TC(tp, wcslcat_heap_end);
2102 	ATF_TP_ADD_TC(tp, wcslcat_heap_after_end);
2103 	ATF_TP_ADD_TC(tp, wcsncat_before_end);
2104 	ATF_TP_ADD_TC(tp, wcsncat_end);
2105 	ATF_TP_ADD_TC(tp, wcsncat_heap_before_end);
2106 	ATF_TP_ADD_TC(tp, wcsncat_heap_end);
2107 	ATF_TP_ADD_TC(tp, wcsncat_heap_after_end);
2108 	ATF_TP_ADD_TC(tp, wcscpy_before_end);
2109 	ATF_TP_ADD_TC(tp, wcscpy_end);
2110 	ATF_TP_ADD_TC(tp, wcscpy_heap_before_end);
2111 	ATF_TP_ADD_TC(tp, wcscpy_heap_end);
2112 	ATF_TP_ADD_TC(tp, wcscpy_heap_after_end);
2113 	ATF_TP_ADD_TC(tp, wcslcpy_before_end);
2114 	ATF_TP_ADD_TC(tp, wcslcpy_end);
2115 	ATF_TP_ADD_TC(tp, wcslcpy_heap_before_end);
2116 	ATF_TP_ADD_TC(tp, wcslcpy_heap_end);
2117 	ATF_TP_ADD_TC(tp, wcslcpy_heap_after_end);
2118 	ATF_TP_ADD_TC(tp, wcsncpy_before_end);
2119 	ATF_TP_ADD_TC(tp, wcsncpy_end);
2120 	ATF_TP_ADD_TC(tp, wcsncpy_heap_before_end);
2121 	ATF_TP_ADD_TC(tp, wcsncpy_heap_end);
2122 	ATF_TP_ADD_TC(tp, wcsncpy_heap_after_end);
2123 	return (atf_no_error());
2124 }
2125