1 /* Copyright (C) 2004-2023 Free Software Foundation, Inc.
2 Copyright The GNU Toolchain Authors.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 /* This file tests gets. Force it to be declared. */
21 #undef __GLIBC_USE_DEPRECATED_GETS
22 #define __GLIBC_USE_DEPRECATED_GETS 1
37 #include <sys/select.h>
38 #include <sys/socket.h>
42 #include <support/temp_file.h>
43 #include <support/support.h>
46 # define MEMPCPY memcpy
47 # define WMEMPCPY wmemcpy
48 # define MEMPCPY_RET(x) 0
49 # define WMEMPCPY_RET(x) 0
51 # define MEMPCPY mempcpy
52 # define WMEMPCPY wmempcpy
53 # define MEMPCPY_RET(x) __builtin_strlen (x)
54 # define WMEMPCPY_RET(x) wcslen (x)
57 #define obstack_chunk_alloc malloc
58 #define obstack_chunk_free free
60 static char *temp_filename
;
63 do_prepare (int argc
, char *argv
[])
65 int temp_fd
= create_temp_file ("tst-chk1.", &temp_filename
);
68 printf ("cannot create temporary file: %m\n");
72 const char *strs
= "abcdefgh\nABCDEFGHI\nabcdefghij\nABCDEFGHIJ";
73 if ((size_t) write (temp_fd
, strs
, strlen (strs
)) != strlen (strs
))
75 puts ("could not write test strings into file");
76 unlink (temp_filename
);
80 #define PREPARE do_prepare
82 static volatile int chk_fail_ok
;
83 static volatile int ret
;
84 static jmp_buf chk_fail_buf
;
92 longjmp (chk_fail_buf
, 1);
98 #if __USE_FORTIFY_LEVEL == 3
99 volatile size_t buf_size
= 10;
103 #define buf_size sizeof (buf)
106 static volatile size_t l0
;
107 static volatile char *p
;
108 static volatile wchar_t *wp
;
109 static const char *str1
= "JIHGFEDCBA";
110 static const char *str2
= "F";
111 static const char *str3
= "%s%n%s%n";
112 static const char *str4
= "Hello, ";
113 static const char *str5
= "World!\n";
114 static const wchar_t *wstr1
= L
"JIHGFEDCBA";
115 static const wchar_t *wstr2
= L
"F";
116 static const wchar_t *wstr3
= L
"%s%n%s%n";
117 static const wchar_t *wstr4
= L
"Hello, ";
118 static const wchar_t *wstr5
= L
"World!\n";
119 static char buf2
[10] = "%s";
120 static int num1
= 67;
121 static int num2
= 987654;
124 do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
125 #define CHK_FAIL_START \
127 if (! setjmp (chk_fail_buf)) \
129 #define CHK_FAIL_END \
133 #if __USE_FORTIFY_LEVEL >= 2 && (!defined __cplusplus || defined __va_arg_pack)
134 # define CHK_FAIL2_START CHK_FAIL_START
135 # define CHK_FAIL2_END CHK_FAIL_END
137 # define CHK_FAIL2_START
138 # define CHK_FAIL2_END
144 #if __USE_FORTIFY_LEVEL == 3
145 char *buf
= (char *) malloc (buf_size
);
146 wchar_t *wbuf
= (wchar_t *) malloc (buf_size
* sizeof (wchar_t));
148 set_fortify_handler (handler
);
150 struct A
{ char buf1
[9]; char buf2
[1]; } a
;
151 struct wA
{ wchar_t buf1
[9]; wchar_t buf2
[1]; } wa
;
153 printf ("Test checking routines at fortify level %d\n",
154 #ifdef __USE_FORTIFY_LEVEL
155 (int) __USE_FORTIFY_LEVEL
161 #if defined __USE_FORTIFY_LEVEL && !defined __fortify_function
162 printf ("Test skipped");
167 /* These ops can be done without runtime checking of object size. */
168 memcpy (buf
, "abcdefghij", 10);
169 memmove (buf
+ 1, buf
, 9);
170 if (memcmp (buf
, "aabcdefghi", 10))
173 memcpy (buf
, "abcdefghij", 10);
174 bcopy (buf
, buf
+ 1, 9);
175 if (memcmp (buf
, "aabcdefghi", 10))
178 if (MEMPCPY (buf
+ 5, "abcde", 5) != buf
+ 5 + MEMPCPY_RET ("abcde")
179 || memcmp (buf
, "aabcdabcde", 10))
182 memset (buf
+ 8, 'j', 2);
183 if (memcmp (buf
, "aabcdabcjj", 10))
187 if (memcmp (buf
, "aabcdabc\0\0", 10))
190 explicit_bzero (buf
+ 6, 4);
191 if (memcmp (buf
, "aabcda\0\0\0\0", 10))
194 strcpy (buf
+ 4, "EDCBA");
195 if (memcmp (buf
, "aabcEDCBA", 10))
198 if (stpcpy (buf
+ 8, "F") != buf
+ 9 || memcmp (buf
, "aabcEDCBF", 10))
201 strncpy (buf
+ 6, "X", 4);
202 if (memcmp (buf
, "aabcEDX\0\0", 10))
205 if (sprintf (buf
+ 7, "%s", "67") != 2 || memcmp (buf
, "aabcEDX67", 10))
208 if (snprintf (buf
+ 7, 3, "%s", "987654") != 6
209 || memcmp (buf
, "aabcEDX98", 10))
212 /* These ops need runtime checking, but shouldn't __chk_fail. */
213 memcpy (buf
, "abcdefghij", l0
+ 10);
214 memmove (buf
+ 1, buf
, l0
+ 9);
215 if (memcmp (buf
, "aabcdefghi", 10))
218 memcpy (buf
, "abcdefghij", l0
+ 10);
219 bcopy (buf
, buf
+ 1, l0
+ 9);
220 if (memcmp (buf
, "aabcdefghi", 10))
223 if (MEMPCPY (buf
+ 5, "abcde", l0
+ 5) != buf
+ 5 + MEMPCPY_RET ("abcde")
224 || memcmp (buf
, "aabcdabcde", 10))
227 memset (buf
+ 8, 'j', l0
+ 2);
228 if (memcmp (buf
, "aabcdabcjj", 10))
231 bzero (buf
+ 8, l0
+ 2);
232 if (memcmp (buf
, "aabcdabc\0\0", 10))
235 explicit_bzero (buf
+ 6, l0
+ 4);
236 if (memcmp (buf
, "aabcda\0\0\0\0", 10))
239 strcpy (buf
+ 4, str1
+ 5);
240 if (memcmp (buf
, "aabcEDCBA", 10))
243 if (stpcpy (buf
+ 8, str2
) != buf
+ 9 || memcmp (buf
, "aabcEDCBF", 10))
246 strncpy (buf
+ 6, "X", l0
+ 4);
247 if (memcmp (buf
, "aabcEDX\0\0", 10))
250 if (stpncpy (buf
+ 5, "cd", l0
+ 5) != buf
+ 7
251 || memcmp (buf
, "aabcEcd\0\0", 10))
254 if (sprintf (buf
+ 7, "%d", num1
) != 2 || memcmp (buf
, "aabcEcd67", 10))
257 if (snprintf (buf
+ 7, 3, "%d", num2
) != 6 || memcmp (buf
, "aabcEcd98", 10))
262 if (memcmp (buf
, "aabcEcd9A", 10))
266 strncat (buf
, "ZYXWV", l0
+ 2);
267 if (memcmp (buf
, "aabcEcdZY", 10))
270 /* The following tests are supposed to succeed at all fortify
271 levels, even though they overflow a.buf1 into a.buf2. */
272 memcpy (a
.buf1
, "abcdefghij", l0
+ 10);
273 memmove (a
.buf1
+ 1, a
.buf1
, l0
+ 9);
274 if (memcmp (a
.buf1
, "aabcdefghi", 10))
277 memcpy (a
.buf1
, "abcdefghij", l0
+ 10);
278 bcopy (a
.buf1
, a
.buf1
+ 1, l0
+ 9);
279 if (memcmp (a
.buf1
, "aabcdefghi", 10))
282 if (MEMPCPY (a
.buf1
+ 5, "abcde", l0
+ 5)
283 != a
.buf1
+ 5 + MEMPCPY_RET ("abcde")
284 || memcmp (a
.buf1
, "aabcdabcde", 10))
287 memset (a
.buf1
+ 8, 'j', l0
+ 2);
288 if (memcmp (a
.buf1
, "aabcdabcjj", 10))
291 bzero (a
.buf1
+ 8, l0
+ 2);
292 if (memcmp (a
.buf1
, "aabcdabc\0\0", 10))
295 explicit_bzero (a
.buf1
+ 6, l0
+ 4);
296 if (memcmp (a
.buf1
, "aabcda\0\0\0\0", 10))
299 #if __USE_FORTIFY_LEVEL < 2
300 /* The following tests are supposed to crash with -D_FORTIFY_SOURCE=2
301 and sufficient GCC support, as the string operations overflow
302 from a.buf1 into a.buf2. */
303 strcpy (a
.buf1
+ 4, str1
+ 5);
304 if (memcmp (a
.buf1
, "aabcEDCBA", 10))
307 if (stpcpy (a
.buf1
+ 8, str2
) != a
.buf1
+ 9
308 || memcmp (a
.buf1
, "aabcEDCBF", 10))
311 strncpy (a
.buf1
+ 6, "X", l0
+ 4);
312 if (memcmp (a
.buf1
, "aabcEDX\0\0", 10))
315 if (sprintf (a
.buf1
+ 7, "%d", num1
) != 2
316 || memcmp (a
.buf1
, "aabcEDX67", 10))
319 if (snprintf (a
.buf1
+ 7, 3, "%d", num2
) != 6
320 || memcmp (a
.buf1
, "aabcEDX98", 10))
323 a
.buf1
[l0
+ 8] = '\0';
324 strcat (a
.buf1
, "A");
325 if (memcmp (a
.buf1
, "aabcEDX9A", 10))
328 a
.buf1
[l0
+ 7] = '\0';
329 strncat (a
.buf1
, "ZYXWV", l0
+ 2);
330 if (memcmp (a
.buf1
, "aabcEDXZY", 10))
335 #if __USE_FORTIFY_LEVEL >= 1
336 /* Now check if all buffer overflows are caught at runtime.
337 N.B. All tests involving a length parameter need to be done
338 twice: once with the length a compile-time constant, once without. */
341 memcpy (buf
+ 1, "abcdefghij", 10);
345 memcpy (buf
+ 1, "abcdefghij", l0
+ 10);
349 memmove (buf
+ 2, buf
+ 1, 9);
353 memmove (buf
+ 2, buf
+ 1, l0
+ 9);
357 bcopy (buf
+ 1, buf
+ 2, 9);
361 bcopy (buf
+ 1, buf
+ 2, l0
+ 9);
366 p
= (char *) mempcpy (buf
+ 6, "abcde", 5);
370 p
= (char *) mempcpy (buf
+ 6, "abcde", l0
+ 5);
375 memset (buf
+ 9, 'j', 2);
379 memset (buf
+ 9, 'j', l0
+ 2);
387 bzero (buf
+ 9, l0
+ 2);
391 explicit_bzero (buf
+ 9, 2);
395 explicit_bzero (buf
+ 9, l0
+ 2);
399 strcpy (buf
+ 5, str1
+ 5);
403 p
= stpcpy (buf
+ 9, str2
);
407 strncpy (buf
+ 7, "X", 4);
411 strncpy (buf
+ 7, "X", l0
+ 4);
415 stpncpy (buf
+ 6, "cd", 5);
419 stpncpy (buf
+ 6, "cd", l0
+ 5);
422 # if !defined __cplusplus || defined __va_arg_pack
424 sprintf (buf
+ 8, "%d", num1
);
428 snprintf (buf
+ 8, 3, "%d", num2
);
432 snprintf (buf
+ 8, l0
+ 3, "%d", num2
);
436 swprintf (wbuf
+ 8, 3, L
"%d", num1
);
440 swprintf (wbuf
+ 8, l0
+ 3, L
"%d", num1
);
444 memcpy (buf
, str1
+ 2, 9);
449 memcpy (buf
, str1
+ 3, 8);
451 strncat (buf
, "ZYXWV", 3);
454 memcpy (buf
, str1
+ 3, 8);
456 strncat (buf
, "ZYXWV", l0
+ 3);
460 memcpy (a
.buf1
+ 1, "abcdefghij", 10);
464 memcpy (a
.buf1
+ 1, "abcdefghij", l0
+ 10);
468 memmove (a
.buf1
+ 2, a
.buf1
+ 1, 9);
472 memmove (a
.buf1
+ 2, a
.buf1
+ 1, l0
+ 9);
476 bcopy (a
.buf1
+ 1, a
.buf1
+ 2, 9);
480 bcopy (a
.buf1
+ 1, a
.buf1
+ 2, l0
+ 9);
485 p
= (char *) mempcpy (a
.buf1
+ 6, "abcde", 5);
489 p
= (char *) mempcpy (a
.buf1
+ 6, "abcde", l0
+ 5);
494 memset (a
.buf1
+ 9, 'j', 2);
498 memset (a
.buf1
+ 9, 'j', l0
+ 2);
502 bzero (a
.buf1
+ 9, 2);
506 bzero (a
.buf1
+ 9, l0
+ 2);
510 explicit_bzero (a
.buf1
+ 9, 2);
514 explicit_bzero (a
.buf1
+ 9, l0
+ 2);
517 # if __USE_FORTIFY_LEVEL >= 2
524 strcpy (a
.buf1
+ (O
+ 4), str1
+ 5);
528 p
= stpcpy (a
.buf1
+ (O
+ 8), str2
);
532 strncpy (a
.buf1
+ (O
+ 6), "X", 4);
536 strncpy (a
.buf1
+ (O
+ 6), "X", l0
+ 4);
540 strlcpy (a
.buf1
+ (O
+ 6), "X", 4);
544 strlcpy (a
.buf1
+ (O
+ 6), "X", l0
+ 4);
548 char *volatile buf2
= buf
;
549 if (strlcpy (buf2
, "a", sizeof (buf
) + 1) != 1)
553 # if !defined __cplusplus || defined __va_arg_pack
555 sprintf (a
.buf1
+ (O
+ 7), "%d", num1
);
559 snprintf (a
.buf1
+ (O
+ 7), 3, "%d", num2
);
563 snprintf (a
.buf1
+ (O
+ 7), l0
+ 3, "%d", num2
);
567 memcpy (a
.buf1
, str1
+ (3 - O
), 8 + O
);
569 strcat (a
.buf1
, "AB");
572 memcpy (a
.buf1
, str1
+ (4 - O
), 7 + O
);
574 strncat (a
.buf1
, "ZYXWV", l0
+ 3);
577 memset (a
.buf1
, 0, sizeof (a
.buf1
));
579 strlcat (a
.buf1
+ (O
+ 6), "X", 4);
582 memset (a
.buf1
, 0, sizeof (a
.buf1
));
584 strlcat (a
.buf1
+ (O
+ 6), "X", l0
+ 4);
589 char *volatile buf2
= buf
;
590 if (strlcat (buf2
, "a", sizeof (buf
) + 1) != 1)
596 /* These ops can be done without runtime checking of object size. */
597 wmemcpy (wbuf
, L
"abcdefghij", 10);
598 wmemmove (wbuf
+ 1, wbuf
, 9);
599 if (wmemcmp (wbuf
, L
"aabcdefghi", 10))
602 if (WMEMPCPY (wbuf
+ 5, L
"abcde", 5) != wbuf
+ 5 + WMEMPCPY_RET (L
"abcde")
603 || wmemcmp (wbuf
, L
"aabcdabcde", 10))
606 wmemset (wbuf
+ 8, L
'j', 2);
607 if (wmemcmp (wbuf
, L
"aabcdabcjj", 10))
610 wcscpy (wbuf
+ 4, L
"EDCBA");
611 if (wmemcmp (wbuf
, L
"aabcEDCBA", 10))
614 if (wcpcpy (wbuf
+ 8, L
"F") != wbuf
+ 9 || wmemcmp (wbuf
, L
"aabcEDCBF", 10))
617 wcsncpy (wbuf
+ 6, L
"X", 4);
618 if (wmemcmp (wbuf
, L
"aabcEDX\0\0", 10))
621 if (swprintf (wbuf
+ 7, 3, L
"%ls", L
"987654") >= 0
622 || wmemcmp (wbuf
, L
"aabcEDX98", 10))
625 if (swprintf (wbuf
+ 7, 3, L
"64") != 2
626 || wmemcmp (wbuf
, L
"aabcEDX64", 10))
629 /* These ops need runtime checking, but shouldn't __chk_fail. */
630 wmemcpy (wbuf
, L
"abcdefghij", l0
+ 10);
631 wmemmove (wbuf
+ 1, wbuf
, l0
+ 9);
632 if (wmemcmp (wbuf
, L
"aabcdefghi", 10))
635 if (WMEMPCPY (wbuf
+ 5, L
"abcde", l0
+ 5)
636 != wbuf
+ 5 + WMEMPCPY_RET (L
"abcde")
637 || wmemcmp (wbuf
, L
"aabcdabcde", 10))
640 wmemset (wbuf
+ 8, L
'j', l0
+ 2);
641 if (wmemcmp (wbuf
, L
"aabcdabcjj", 10))
644 wcscpy (wbuf
+ 4, wstr1
+ 5);
645 if (wmemcmp (wbuf
, L
"aabcEDCBA", 10))
648 if (wcpcpy (wbuf
+ 8, wstr2
) != wbuf
+ 9 || wmemcmp (wbuf
, L
"aabcEDCBF", 10))
651 wcsncpy (wbuf
+ 6, L
"X", l0
+ 4);
652 if (wmemcmp (wbuf
, L
"aabcEDX\0\0", 10))
655 if (wcpncpy (wbuf
+ 5, L
"cd", l0
+ 5) != wbuf
+ 7
656 || wmemcmp (wbuf
, L
"aabcEcd\0\0", 10))
659 if (swprintf (wbuf
+ 7, 3, L
"%d", num2
) >= 0
660 || wmemcmp (wbuf
, L
"aabcEcd98", 10))
663 wbuf
[l0
+ 8] = L
'\0';
665 if (wmemcmp (wbuf
, L
"aabcEcd9A", 10))
668 wbuf
[l0
+ 7] = L
'\0';
669 wcsncat (wbuf
, L
"ZYXWV", l0
+ 2);
670 if (wmemcmp (wbuf
, L
"aabcEcdZY", 10))
673 wmemcpy (wa
.buf1
, L
"abcdefghij", l0
+ 10);
674 wmemmove (wa
.buf1
+ 1, wa
.buf1
, l0
+ 9);
675 if (wmemcmp (wa
.buf1
, L
"aabcdefghi", 10))
678 if (WMEMPCPY (wa
.buf1
+ 5, L
"abcde", l0
+ 5)
679 != wa
.buf1
+ 5 + WMEMPCPY_RET (L
"abcde")
680 || wmemcmp (wa
.buf1
, L
"aabcdabcde", 10))
683 wmemset (wa
.buf1
+ 8, L
'j', l0
+ 2);
684 if (wmemcmp (wa
.buf1
, L
"aabcdabcjj", 10))
687 #if __USE_FORTIFY_LEVEL < 2
688 /* The following tests are supposed to crash with -D_FORTIFY_SOURCE=2
689 and sufficient GCC support, as the string operations overflow
690 from a.buf1 into a.buf2. */
691 wcscpy (wa
.buf1
+ 4, wstr1
+ 5);
692 if (wmemcmp (wa
.buf1
, L
"aabcEDCBA", 10))
695 if (wcpcpy (wa
.buf1
+ 8, wstr2
) != wa
.buf1
+ 9
696 || wmemcmp (wa
.buf1
, L
"aabcEDCBF", 10))
699 wcsncpy (wa
.buf1
+ 6, L
"X", l0
+ 4);
700 if (wmemcmp (wa
.buf1
, L
"aabcEDX\0\0", 10))
703 if (swprintf (wa
.buf1
+ 7, 3, L
"%d", num2
) >= 0
704 || wmemcmp (wa
.buf1
, L
"aabcEDX98", 10))
707 wa
.buf1
[l0
+ 8] = L
'\0';
708 wcscat (wa
.buf1
, L
"A");
709 if (wmemcmp (wa
.buf1
, L
"aabcEDX9A", 10))
712 wa
.buf1
[l0
+ 7] = L
'\0';
713 wcsncat (wa
.buf1
, L
"ZYXWV", l0
+ 2);
714 if (wmemcmp (wa
.buf1
, L
"aabcEDXZY", 10))
719 #if __USE_FORTIFY_LEVEL >= 1
720 /* Now check if all buffer overflows are caught at runtime.
721 N.B. All tests involving a length parameter need to be done
722 twice: once with the length a compile-time constant, once without. */
725 wmemcpy (wbuf
+ 1, L
"abcdefghij", 10);
729 wmemcpy (wbuf
+ 1, L
"abcdefghij", l0
+ 10);
733 wmemcpy (wbuf
+ 9, L
"abcdefghij", 10);
737 wmemcpy (wbuf
+ 9, L
"abcdefghij", l0
+ 10);
741 wmemmove (wbuf
+ 2, wbuf
+ 1, 9);
745 wmemmove (wbuf
+ 2, wbuf
+ 1, l0
+ 9);
750 wp
= wmempcpy (wbuf
+ 6, L
"abcde", 5);
754 wp
= wmempcpy (wbuf
+ 6, L
"abcde", l0
+ 5);
759 wmemset (wbuf
+ 9, L
'j', 2);
763 wmemset (wbuf
+ 9, L
'j', l0
+ 2);
767 wcscpy (wbuf
+ 5, wstr1
+ 5);
771 wp
= wcpcpy (wbuf
+ 9, wstr2
);
775 wcsncpy (wbuf
+ 7, L
"X", 4);
779 wcsncpy (wbuf
+ 7, L
"X", l0
+ 4);
783 wcsncpy (wbuf
+ 9, L
"XABCDEFGH", 8);
787 wcslcpy (wbuf
+ 7, L
"X", 4);
791 wcslcpy (wbuf
+ 7, L
"X", l0
+ 4);
795 wcslcpy (wbuf
+ 9, L
"XABCDEFGH", 8);
799 wcpncpy (wbuf
+ 9, L
"XABCDEFGH", 8);
803 wcpncpy (wbuf
+ 6, L
"cd", 5);
807 wcpncpy (wbuf
+ 6, L
"cd", l0
+ 5);
810 wmemcpy (wbuf
, wstr1
+ 2, 9);
812 wcscat (wbuf
, L
"AB");
815 wmemcpy (wbuf
, wstr1
+ 3, 8);
817 wcsncat (wbuf
, L
"ZYXWV", l0
+ 3);
820 wmemcpy (wbuf
, wstr1
+ 4, 7);
822 wcslcat (wbuf
, L
"ZYXWV", l0
+ 11);
826 wmemcpy (wa
.buf1
+ 1, L
"abcdefghij", 10);
830 wmemcpy (wa
.buf1
+ 1, L
"abcdefghij", l0
+ 10);
834 wmemmove (wa
.buf1
+ 2, wa
.buf1
+ 1, 9);
838 wmemmove (wa
.buf1
+ 2, wa
.buf1
+ 1, l0
+ 9);
843 wp
= wmempcpy (wa
.buf1
+ 6, L
"abcde", 5);
847 wp
= wmempcpy (wa
.buf1
+ 6, L
"abcde", l0
+ 5);
852 wmemset (wa
.buf1
+ 9, L
'j', 2);
856 wmemset (wa
.buf1
+ 9, L
'j', l0
+ 2);
859 #if __USE_FORTIFY_LEVEL >= 2
866 wcscpy (wa
.buf1
+ (O
+ 4), wstr1
+ 5);
870 wp
= wcpcpy (wa
.buf1
+ (O
+ 8), wstr2
);
874 wcsncpy (wa
.buf1
+ (O
+ 6), L
"X", 4);
878 wcsncpy (wa
.buf1
+ (O
+ 6), L
"X", l0
+ 4);
881 wmemcpy (wa
.buf1
, wstr1
+ (3 - O
), 8 + O
);
883 wcscat (wa
.buf1
, L
"AB");
886 wmemcpy (wa
.buf1
, wstr1
+ (4 - O
), 7 + O
);
888 wcsncat (wa
.buf1
, L
"ZYXWV", l0
+ 3);
893 /* Now checks for %n protection. */
895 /* Constant literals passed directly are always ok
896 (even with warnings about possible bugs from GCC). */
898 if (sprintf (buf
, "%s%n%s%n", str2
, &n1
, str2
, &n2
) != 2
899 || n1
!= 1 || n2
!= 2)
902 /* In this case the format string is not known at compile time,
903 but resides in read-only memory, so is ok. */
904 if (snprintf (buf
, 4, str3
, str2
, &n1
, str2
, &n2
) != 2
905 || n1
!= 1 || n2
!= 2)
908 strcpy (buf2
+ 2, "%n%s%n");
909 /* When the format string is writable and contains %n,
910 with -D_FORTIFY_SOURCE=2 it causes __chk_fail. */
912 if (sprintf (buf
, buf2
, str2
, &n1
, str2
, &n1
) != 2)
917 if (snprintf (buf
, 3, buf2
, str2
, &n1
, str2
, &n1
) != 2)
921 /* But if there is no %n, even writable format string
924 if (sprintf (buf
, buf2
+ 4, str2
) != 1)
927 /* Constant literals passed directly are always ok
928 (even with warnings about possible bugs from GCC). */
929 if (printf ("%s%n%s%n", str4
, &n1
, str5
, &n2
) != 14
930 || n1
!= 7 || n2
!= 14)
933 /* In this case the format string is not known at compile time,
934 but resides in read-only memory, so is ok. */
935 if (printf (str3
, str4
, &n1
, str5
, &n2
) != 14
936 || n1
!= 7 || n2
!= 14)
939 strcpy (buf2
+ 2, "%n%s%n");
940 /* When the format string is writable and contains %n,
941 with -D_FORTIFY_SOURCE=2 it causes __chk_fail. */
943 if (printf (buf2
, str4
, &n1
, str5
, &n1
) != 14)
947 /* But if there is no %n, even writable format string
950 if (printf (buf2
+ 4, str5
) != 7)
955 /* Constant literals passed directly are always ok
956 (even with warnings about possible bugs from GCC). */
957 if (fprintf (fp
, "%s%n%s%n", str4
, &n1
, str5
, &n2
) != 14
958 || n1
!= 7 || n2
!= 14)
961 /* In this case the format string is not known at compile time,
962 but resides in read-only memory, so is ok. */
963 if (fprintf (fp
, str3
, str4
, &n1
, str5
, &n2
) != 14
964 || n1
!= 7 || n2
!= 14)
967 strcpy (buf2
+ 2, "%n%s%n");
968 /* When the format string is writable and contains %n,
969 with -D_FORTIFY_SOURCE=2 it causes __chk_fail. */
971 if (fprintf (fp
, buf2
, str4
, &n1
, str5
, &n1
) != 14)
975 /* But if there is no %n, even writable format string
978 if (fprintf (fp
, buf2
+ 4, str5
) != 7)
983 strcpy (buf2
+ 2, "%n%s%n");
984 /* When the format string is writable and contains %n,
985 with -D_FORTIFY_SOURCE=2 it causes __chk_fail. */
987 if (asprintf (&my_ptr
, buf2
, str4
, &n1
, str5
, &n1
) != 14)
996 if (obstack_printf (&obs
, buf2
, str4
, &n1
, str5
, &n1
) != 14)
999 obstack_free (&obs
, NULL
);
1002 if (asprintf (&my_ptr
, "%s%n%s%n", str4
, &n1
, str5
, &n1
) != 14)
1007 obstack_init (&obs
);
1008 if (obstack_printf (&obs
, "%s%n%s%n", str4
, &n1
, str5
, &n1
) != 14)
1010 obstack_free (&obs
, NULL
);
1013 if (freopen (temp_filename
, "r", stdin
) == NULL
)
1015 puts ("could not open temporary file");
1019 if (gets (buf
) != buf
|| memcmp (buf
, "abcdefgh", 9))
1021 if (gets (buf
) != buf
|| memcmp (buf
, "ABCDEFGHI", 10))
1024 #if __USE_FORTIFY_LEVEL >= 1
1026 if (gets (buf
) != buf
)
1033 if (fgets (buf
, buf_size
, stdin
) != buf
1034 || memcmp (buf
, "abcdefgh\n", 10))
1036 if (fgets (buf
, buf_size
, stdin
) != buf
|| memcmp (buf
, "ABCDEFGHI", 10))
1041 if (fgets (buf
, l0
+ buf_size
, stdin
) != buf
1042 || memcmp (buf
, "abcdefgh\n", 10))
1045 #if __USE_FORTIFY_LEVEL >= 1
1047 if (fgets (buf
, buf_size
+ 1, stdin
) != buf
)
1052 if (fgets (buf
, l0
+ buf_size
+ 1, stdin
) != buf
)
1060 if (fgets_unlocked (buf
, buf_size
, stdin
) != buf
1061 || memcmp (buf
, "abcdefgh\n", 10))
1063 if (fgets_unlocked (buf
, buf_size
, stdin
) != buf
1064 || memcmp (buf
, "ABCDEFGHI", 10))
1069 if (fgets_unlocked (buf
, l0
+ buf_size
, stdin
) != buf
1070 || memcmp (buf
, "abcdefgh\n", 10))
1073 #if __USE_FORTIFY_LEVEL >= 1
1075 if (fgets_unlocked (buf
, buf_size
+ 1, stdin
) != buf
)
1080 if (fgets_unlocked (buf
, l0
+ buf_size
+ 1, stdin
) != buf
)
1088 if (fread (buf
, 1, buf_size
, stdin
) != buf_size
1089 || memcmp (buf
, "abcdefgh\nA", 10))
1091 if (fread (buf
, buf_size
, 1, stdin
) != 1
1092 || memcmp (buf
, "BCDEFGHI\na", 10))
1097 if (fread (buf
, l0
+ 1, buf_size
, stdin
) != buf_size
1098 || memcmp (buf
, "abcdefgh\nA", 10))
1100 if (fread (buf
, buf_size
, l0
+ 1, stdin
) != 1
1101 || memcmp (buf
, "BCDEFGHI\na", 10))
1104 #if __USE_FORTIFY_LEVEL >= 1
1106 if (fread (buf
, 1, buf_size
+ 1, stdin
) != buf_size
+ 1)
1111 if (fread (buf
, buf_size
+ 1, l0
+ 1, stdin
) != 1)
1118 if (fread_unlocked (buf
, 1, buf_size
, stdin
) != buf_size
1119 || memcmp (buf
, "abcdefgh\nA", 10))
1121 if (fread_unlocked (buf
, buf_size
, 1, stdin
) != 1
1122 || memcmp (buf
, "BCDEFGHI\na", 10))
1127 if (fread_unlocked (buf
, 1, 4, stdin
) != 4
1128 || memcmp (buf
, "abcdFGHI\na", 10))
1130 if (fread_unlocked (buf
, 4, 1, stdin
) != 1
1131 || memcmp (buf
, "efghFGHI\na", 10))
1136 if (fread_unlocked (buf
, l0
+ 1, buf_size
, stdin
) != buf_size
1137 || memcmp (buf
, "abcdefgh\nA", 10))
1139 if (fread_unlocked (buf
, buf_size
, l0
+ 1, stdin
) != 1
1140 || memcmp (buf
, "BCDEFGHI\na", 10))
1143 #if __USE_FORTIFY_LEVEL >= 1
1145 if (fread_unlocked (buf
, 1, buf_size
+ 1, stdin
) != buf_size
+ 1)
1150 if (fread_unlocked (buf
, buf_size
+ 1, l0
+ 1, stdin
) != 1)
1155 lseek (fileno (stdin
), 0, SEEK_SET
);
1157 if (read (fileno (stdin
), buf
, buf_size
- 1) != buf_size
- 1
1158 || memcmp (buf
, "abcdefgh\n", 9))
1160 if (read (fileno (stdin
), buf
, buf_size
- 1) != buf_size
- 1
1161 || memcmp (buf
, "ABCDEFGHI", 9))
1164 lseek (fileno (stdin
), 0, SEEK_SET
);
1166 if (read (fileno (stdin
), buf
, l0
+ buf_size
- 1) != buf_size
- 1
1167 || memcmp (buf
, "abcdefgh\n", 9))
1170 #if __USE_FORTIFY_LEVEL >= 1
1172 if (read (fileno (stdin
), buf
, buf_size
+ 1) != buf_size
+ 1)
1177 if (read (fileno (stdin
), buf
, l0
+ buf_size
+ 1) != buf_size
+ 1)
1182 if (pread (fileno (stdin
), buf
, buf_size
- 1, buf_size
- 2)
1184 || memcmp (buf
, "\nABCDEFGH", 9))
1186 if (pread (fileno (stdin
), buf
, buf_size
- 1, 0) != buf_size
- 1
1187 || memcmp (buf
, "abcdefgh\n", 9))
1189 if (pread (fileno (stdin
), buf
, l0
+ buf_size
- 1, buf_size
- 3)
1191 || memcmp (buf
, "h\nABCDEFG", 9))
1194 #if __USE_FORTIFY_LEVEL >= 1
1196 if (pread (fileno (stdin
), buf
, buf_size
+ 1, 2 * buf_size
)
1202 if (pread (fileno (stdin
), buf
, l0
+ buf_size
+ 1, 2 * buf_size
)
1208 if (pread64 (fileno (stdin
), buf
, buf_size
- 1, buf_size
- 2)
1210 || memcmp (buf
, "\nABCDEFGH", 9))
1212 if (pread64 (fileno (stdin
), buf
, buf_size
- 1, 0) != buf_size
- 1
1213 || memcmp (buf
, "abcdefgh\n", 9))
1215 if (pread64 (fileno (stdin
), buf
, l0
+ buf_size
- 1, buf_size
- 3)
1217 || memcmp (buf
, "h\nABCDEFG", 9))
1220 #if __USE_FORTIFY_LEVEL >= 1
1222 if (pread64 (fileno (stdin
), buf
, buf_size
+ 1, 2 * buf_size
)
1228 if (pread64 (fileno (stdin
), buf
, l0
+ buf_size
+ 1, 2 * buf_size
)
1234 if (freopen (temp_filename
, "r", stdin
) == NULL
)
1236 puts ("could not open temporary file");
1240 if (fseek (stdin
, 9 + 10 + 11, SEEK_SET
))
1242 puts ("could not seek in test file");
1246 #if __USE_FORTIFY_LEVEL >= 1
1248 if (gets (buf
) != buf
)
1253 /* Check whether missing N$ formats are detected. */
1255 printf ("%3$d\n", 1, 2, 3, 4);
1259 fprintf (stdout
, "%3$d\n", 1, 2, 3, 4);
1263 sprintf (buf
, "%3$d\n", 1, 2, 3, 4);
1267 snprintf (buf
, buf_size
, "%3$d\n", 1, 2, 3, 4);
1271 if (socketpair (PF_UNIX
, SOCK_STREAM
, 0, sp
))
1275 const char *sendstr
= "abcdefgh\nABCDEFGH\n0123456789\n";
1276 if ((size_t) send (sp
[0], sendstr
, strlen (sendstr
), 0)
1277 != strlen (sendstr
))
1281 if (recv (sp
[1], recvbuf
, sizeof recvbuf
, MSG_PEEK
)
1283 || memcmp (recvbuf
, sendstr
, sizeof recvbuf
) != 0)
1286 if (recv (sp
[1], recvbuf
+ 6, l0
+ sizeof recvbuf
- 7, MSG_PEEK
)
1287 != sizeof recvbuf
- 7
1288 || memcmp (recvbuf
+ 6, sendstr
, sizeof recvbuf
- 7) != 0)
1291 #if __USE_FORTIFY_LEVEL >= 1
1293 if (recv (sp
[1], recvbuf
+ 1, sizeof recvbuf
, MSG_PEEK
)
1299 if (recv (sp
[1], recvbuf
+ 4, l0
+ sizeof recvbuf
- 3, MSG_PEEK
)
1300 != sizeof recvbuf
- 3)
1306 struct sockaddr_un sa_un
;
1308 sl
= sizeof (sa_un
);
1309 if (recvfrom (sp
[1], recvbuf
, sizeof recvbuf
, MSG_PEEK
,
1310 (struct sockaddr
*) &sa_un
, &sl
)
1312 || memcmp (recvbuf
, sendstr
, sizeof recvbuf
) != 0)
1315 sl
= sizeof (sa_un
);
1316 if (recvfrom (sp
[1], recvbuf
+ 6, l0
+ sizeof recvbuf
- 7, MSG_PEEK
,
1317 (struct sockaddr
*) &sa_un
, &sl
) != sizeof recvbuf
- 7
1318 || memcmp (recvbuf
+ 6, sendstr
, sizeof recvbuf
- 7) != 0)
1321 #if __USE_FORTIFY_LEVEL >= 1
1323 sl
= sizeof (sa_un
);
1324 if (recvfrom (sp
[1], recvbuf
+ 1, sizeof recvbuf
, MSG_PEEK
,
1325 (struct sockaddr
*) &sa_un
, &sl
) != sizeof recvbuf
)
1330 sl
= sizeof (sa_un
);
1331 if (recvfrom (sp
[1], recvbuf
+ 4, l0
+ sizeof recvbuf
- 3, MSG_PEEK
,
1332 (struct sockaddr
*) &sa_un
, &sl
) != sizeof recvbuf
- 3)
1341 char fname
[] = "/tmp/tst-chk1-dir-XXXXXX\0foo";
1342 char *enddir
= strchr (fname
, '\0');
1343 if (mkdtemp (fname
) == NULL
)
1345 printf ("mkdtemp failed: %m\n");
1349 if (symlink ("bar", fname
) != 0)
1352 char readlinkbuf
[4];
1353 if (readlink (fname
, readlinkbuf
, 4) != 3
1354 || memcmp (readlinkbuf
, "bar", 3) != 0)
1356 if (readlink (fname
, readlinkbuf
+ 1, l0
+ 3) != 3
1357 || memcmp (readlinkbuf
, "bbar", 4) != 0)
1360 #if __USE_FORTIFY_LEVEL >= 1
1362 if (readlink (fname
, readlinkbuf
+ 2, l0
+ 3) != 3)
1367 if (readlink (fname
, readlinkbuf
+ 3, 4) != 3)
1372 int tmpfd
= open ("/tmp", O_RDONLY
| O_DIRECTORY
);
1376 if (readlinkat (tmpfd
, fname
+ sizeof ("/tmp/") - 1, readlinkbuf
, 4) != 3
1377 || memcmp (readlinkbuf
, "bar", 3) != 0)
1379 if (readlinkat (tmpfd
, fname
+ sizeof ("/tmp/") - 1, readlinkbuf
+ 1,
1381 || memcmp (readlinkbuf
, "bbar", 4) != 0)
1384 #if __USE_FORTIFY_LEVEL >= 1
1386 if (readlinkat (tmpfd
, fname
+ sizeof ("/tmp/") - 1, readlinkbuf
+ 2,
1392 if (readlinkat (tmpfd
, fname
+ sizeof ("/tmp/") - 1, readlinkbuf
+ 3,
1400 char *cwd1
= getcwd (NULL
, 0);
1404 char *cwd2
= getcwd (NULL
, 250);
1410 if (strcmp (cwd1
, cwd2
) != 0)
1417 char *cwd3
= getcwd (NULL
, 0);
1420 if (strcmp (fname
, cwd3
) != 0)
1421 printf ("getcwd after chdir is '%s' != '%s',"
1422 "get{c,}wd tests skipped\n", cwd3
, fname
);
1425 char getcwdbuf
[sizeof fname
- 3];
1427 char *cwd4
= getcwd (getcwdbuf
, sizeof getcwdbuf
);
1428 if (cwd4
!= getcwdbuf
1429 || strcmp (getcwdbuf
, fname
) != 0)
1432 cwd4
= getcwd (getcwdbuf
+ 1, l0
+ sizeof getcwdbuf
- 1);
1433 if (cwd4
!= getcwdbuf
+ 1
1434 || getcwdbuf
[0] != fname
[0]
1435 || strcmp (getcwdbuf
+ 1, fname
) != 0)
1438 #if __USE_FORTIFY_LEVEL >= 1
1440 if (getcwd (getcwdbuf
+ 2, l0
+ sizeof getcwdbuf
)
1446 if (getcwd (getcwdbuf
+ 2, sizeof getcwdbuf
)
1452 if (getwd (getcwdbuf
) != getcwdbuf
1453 || strcmp (getcwdbuf
, fname
) != 0)
1456 if (getwd (getcwdbuf
+ 1) != getcwdbuf
+ 1
1457 || strcmp (getcwdbuf
+ 1, fname
) != 0)
1460 #if __USE_FORTIFY_LEVEL >= 1
1462 if (getwd (getcwdbuf
+ 2) != getcwdbuf
+ 2)
1468 if (chdir (cwd1
) != 0)
1476 if (unlink (fname
) != 0)
1480 if (rmdir (fname
) != 0)
1485 char largebuf
[PATH_MAX
];
1486 char *realres
= realpath (".", largebuf
);
1487 if (realres
!= largebuf
)
1490 # if __USE_FORTIFY_LEVEL >= 1
1493 realres
= realpath (".", realbuf
);
1494 if (realres
!= realbuf
)
1500 if (setlocale (LC_ALL
, "de_DE.UTF-8") != NULL
)
1502 assert (MB_CUR_MAX
<= 10);
1504 /* First a simple test. */
1506 if (wctomb (enough
, L
'A') != 1)
1509 #if __USE_FORTIFY_LEVEL >= 1
1510 /* We know the wchar_t encoding is ISO 10646. So pick a
1511 character which has a multibyte representation which does not
1515 if (wctomb (smallbuf
, L
'\x100') != 2)
1521 memset (&s
, '\0', sizeof (s
));
1522 if (wcrtomb (enough
, L
'D', &s
) != 1 || enough
[0] != 'D')
1525 #if __USE_FORTIFY_LEVEL >= 1
1526 /* We know the wchar_t encoding is ISO 10646. So pick a
1527 character which has a multibyte representation which does not
1531 if (wcrtomb (smallbuf
, L
'\x100', &s
) != 2)
1535 /* Same input with a large enough buffer and we're good. */
1536 char bigenoughbuf
[2];
1537 if (wcrtomb (bigenoughbuf
, L
'\x100', &s
) != 2)
1541 wchar_t wenough
[10];
1542 memset (&s
, '\0', sizeof (s
));
1543 const char *cp
= "A";
1544 if (mbsrtowcs (wenough
, &cp
, 10, &s
) != 1
1545 || wcscmp (wenough
, L
"A") != 0)
1549 if (mbsrtowcs (wenough
, &cp
, l0
+ 10, &s
) != 2
1550 || wcscmp (wenough
, L
"BC") != 0)
1553 #if __USE_FORTIFY_LEVEL >= 1
1555 wchar_t wsmallbuf
[2];
1557 mbsrtowcs (wsmallbuf
, &cp
, 10, &s
);
1561 /* Bug 29030 regression check */
1563 if (mbsrtowcs (NULL
, &cp
, (size_t)-1, &s
) != 10)
1567 if (mbstowcs (wenough
, cp
, 10) != 1
1568 || wcscmp (wenough
, L
"A") != 0)
1572 if (mbstowcs (wenough
, cp
, l0
+ 10) != 3
1573 || wcscmp (wenough
, L
"DEF") != 0)
1576 #if __USE_FORTIFY_LEVEL >= 1
1578 wchar_t wsmallbuf
[2];
1580 mbstowcs (wsmallbuf
, cp
, 10);
1584 memset (&s
, '\0', sizeof (s
));
1586 wcscpy (wenough
, L
"DEF");
1587 if (mbsnrtowcs (wenough
, &cp
, 1, 10, &s
) != 1
1588 || wcscmp (wenough
, L
"AEF") != 0)
1592 if (mbsnrtowcs (wenough
, &cp
, 1, l0
+ 10, &s
) != 1
1593 || wcscmp (wenough
, L
"IEF") != 0)
1596 #if __USE_FORTIFY_LEVEL >= 1
1598 wchar_t wsmallbuf
[2];
1600 mbsnrtowcs (wsmallbuf
, &cp
, 3, 10, &s
);
1604 memset (&s
, '\0', sizeof (s
));
1605 const wchar_t *wcp
= L
"A";
1606 if (wcsrtombs (enough
, &wcp
, 10, &s
) != 1
1607 || strcmp (enough
, "A") != 0)
1611 if (wcsrtombs (enough
, &wcp
, l0
+ 10, &s
) != 2
1612 || strcmp (enough
, "BC") != 0)
1615 #if __USE_FORTIFY_LEVEL >= 1
1619 wcsrtombs (smallbuf
, &wcp
, 10, &s
);
1623 memset (enough
, 'Z', sizeof (enough
));
1625 if (wcstombs (enough
, wcp
, 10) != 2
1626 || strcmp (enough
, "EF") != 0)
1630 if (wcstombs (enough
, wcp
, l0
+ 10) != 1
1631 || strcmp (enough
, "G") != 0)
1634 #if __USE_FORTIFY_LEVEL >= 1
1638 wcstombs (smallbuf
, wcp
, 10);
1642 memset (&s
, '\0', sizeof (s
));
1644 if (wcsnrtombs (enough
, &wcp
, 1, 10, &s
) != 1
1645 || strcmp (enough
, "A") != 0)
1649 if (wcsnrtombs (enough
, &wcp
, 1, l0
+ 10, &s
) != 1
1650 || strcmp (enough
, "B") != 0)
1653 #if __USE_FORTIFY_LEVEL >= 1
1657 wcsnrtombs (smallbuf
, &wcp
, 3, 10, &s
);
1663 puts ("cannot set locale");
1670 fd
= posix_openpt (O_RDWR
);
1674 if (ptsname_r (fd
, enough
, sizeof (enough
)) != 0)
1677 #if __USE_FORTIFY_LEVEL >= 1
1680 if (ptsname_r (fd
, smallbuf
, sizeof (smallbuf
) + 1) == 0)
1689 confstr (_CS_GNU_LIBC_VERSION
, largebuf
, sizeof (largebuf
));
1690 # if __USE_FORTIFY_LEVEL >= 1
1693 confstr (_CS_GNU_LIBC_VERSION
, smallbuf
, sizeof (largebuf
));
1699 int ngr
= getgroups (5, grpslarge
);
1700 asm volatile ("" : : "r" (ngr
));
1701 #if __USE_FORTIFY_LEVEL >= 1
1704 ngr
= getgroups (5, (gid_t
*) smallbuf
);
1705 asm volatile ("" : : "r" (ngr
));
1709 fd
= open (_PATH_TTY
, O_RDONLY
);
1713 if (ttyname_r (fd
, enough
, sizeof (enough
)) != 0)
1716 #if __USE_FORTIFY_LEVEL >= 1
1719 if (ttyname_r (fd
, smallbuf
, sizeof (smallbuf
) + 1) == 0)
1726 char hostnamelarge
[1000];
1727 gethostname (hostnamelarge
, sizeof (hostnamelarge
));
1728 #if __USE_FORTIFY_LEVEL >= 1
1731 gethostname (smallbuf
, sizeof (hostnamelarge
));
1735 char loginlarge
[1000];
1736 getlogin_r (loginlarge
, sizeof (hostnamelarge
));
1737 #if __USE_FORTIFY_LEVEL >= 1
1740 getlogin_r (smallbuf
, sizeof (loginlarge
));
1744 char domainnamelarge
[1000];
1745 int res
= getdomainname (domainnamelarge
, sizeof (domainnamelarge
));
1746 asm volatile ("" : : "r" (res
));
1747 #if __USE_FORTIFY_LEVEL >= 1
1750 res
= getdomainname (smallbuf
, sizeof (domainnamelarge
));
1751 asm volatile ("" : : "r" (res
));
1758 FD_SET (FD_SETSIZE
- 1, &s
);
1759 #if __USE_FORTIFY_LEVEL >= 1
1761 FD_SET (FD_SETSIZE
, &s
);
1765 FD_SET (l0
+ FD_SETSIZE
, &s
);
1769 FD_CLR (FD_SETSIZE
- 1, &s
);
1770 #if __USE_FORTIFY_LEVEL >= 1
1772 FD_CLR (FD_SETSIZE
, &s
);
1776 FD_SET (l0
+ FD_SETSIZE
, &s
);
1780 FD_ISSET (FD_SETSIZE
- 1, &s
);
1781 #if __USE_FORTIFY_LEVEL >= 1
1783 FD_ISSET (FD_SETSIZE
, &s
);
1787 FD_ISSET (l0
+ FD_SETSIZE
, &s
);
1791 struct pollfd fds
[1];
1792 fds
[0].fd
= STDOUT_FILENO
;
1793 fds
[0].events
= POLLOUT
;
1795 #if __USE_FORTIFY_LEVEL >= 1
1801 poll (fds
, l0
+ 2, 0);
1805 ppoll (fds
, 1, NULL
, NULL
);
1806 # if __USE_FORTIFY_LEVEL >= 1
1808 ppoll (fds
, 2, NULL
, NULL
);
1812 ppoll (fds
, l0
+ 2, NULL
, NULL
);
1820 #include <support/test-driver.c>