Fix p_secstodate overflow handling (bug 22463).
[glibc.git] / stdlib / tst-empty-env.c
blob0b0651d53061c6266bb18a7902b6429b08cdc93a
1 /* Test that passing a NULL value does not hang environment traversal in
2 tunables.
3 Copyright (C) 2017 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 /* The test is useful only when the source is configured with
21 --enable-hardcoded-path-in-tests since otherwise the execve just picks up
22 the system dynamic linker. */
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <unistd.h>
27 #include <errno.h>
29 static int
30 do_test (int argc, char **argv)
32 if (argc == 2)
33 return 0;
35 char envname[] = "FOOBAR";
36 char *filename = program_invocation_name;
37 char *newargv[] = {filename, filename, NULL};
38 char *newenviron[] = {envname, NULL};
40 /* This was reported in Fedora:
42 https://bugzilla.redhat.com/show_bug.cgi?id=1414589
44 If one of the environment variables has no value, then the environment
45 traversal must skip and also advance to the next environment entry. The
46 bug in question would cause this test to hang in an infinite loop. */
47 int ret = execve (filename, newargv, newenviron);
49 if (ret != 0)
50 printf ("execve failed: %m");
52 /* We will reach here only if we fail execve. */
53 return 1;
56 #define TIMEOUT 3
57 #define TEST_FUNCTION_ARGV do_test
58 #include <support/test-driver.c>