1 /* Test for endpwent->getpwent crash for BZ #24695
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
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/>. */
21 #include <sys/types.h>
24 #include <support/support.h>
25 #include <support/check.h>
26 #include <support/xstdlib.h>
28 /* It is entirely allowed to start with a getpwent call without
29 resetting the state of the service via a call to setpwent.
30 You can also call getpwent more times than you have entries in
31 the service, and it should not fail. This test iteratates the
32 database once, gets to the end, and then attempts a second
33 iteration to look for crashes. */
40 /* setpwent is intentionally omitted here. The first call to
41 getpwent detects that it's first and initializes. The second
42 time try_it is called, this "first call" was not detected before
43 the fix, and getpwent would crash. */
45 while ((pw
= getpwent ()) != NULL
)
48 /* We only care if this segfaults or not. */
57 cmd
= xasprintf ("%s/makedb -o /var/db/passwd.db /var/db/passwd.in",
58 support_bindir_prefix
);
67 #include <support/test-driver.c>