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