1 /* test ftw bz26353: Check whether stack overflow occurs when the value
2 of the nopenfd parameter is too large.
4 Copyright (C) 2020-2023 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <https://www.gnu.org/licenses/>. */
25 #include <sys/resource.h>
27 #include <support/temp_file.h>
28 #include <support/capture_subprocess.h>
29 #include <support/check.h>
32 my_func (const char *file
, const struct stat
*sb
, int flag
)
38 get_large_nopenfd (void)
41 TEST_COMPARE (getrlimit (RLIMIT_STACK
, &r
), 0);
42 if (r
.rlim_cur
== RLIM_INFINITY
)
44 r
.rlim_cur
= 8 * 1024 * 1024;
45 TEST_COMPARE (setrlimit (RLIMIT_STACK
, &r
), 0);
47 return (int) r
.rlim_cur
;
53 char *tempdir
= support_create_temp_directory ("tst-bz26353");
54 int large_nopenfd
= get_large_nopenfd ();
55 TEST_COMPARE (ftw (tempdir
, my_func
, large_nopenfd
), 0);
59 /* Check whether stack overflow occurs. */
63 struct support_capture_subprocess result
;
64 result
= support_capture_subprocess (do_ftw
, NULL
);
65 support_capture_subprocess_check (&result
, "bz26353", 0, sc_allow_none
);
66 support_capture_subprocess_free (&result
);
70 #include <support/test-driver.c>