From: Collin Funk Date: Sat, 18 May 2024 01:53:51 +0000 (-0700) Subject: getusershell tests: Fail if empty lines are returned. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=f77eb82cec43e043762c7e746375bc1879aa4849;p=gnulib.git getusershell tests: Fail if empty lines are returned. * tests/test-getusershell.c (first_pass): Check the result of malloc. Make sure '\0' isn't returned from getusershell when there is an empty line in /etc/shells. --- diff --git a/ChangeLog b/ChangeLog index 888ab7fdd7..e1a840eb04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-05-17 Collin Funk + + getusershell tests: Fail if empty lines are returned. + * tests/test-getusershell.c (first_pass): Check the result of malloc. + Make sure '\0' isn't returned from getusershell when there is an empty + line in /etc/shells. + 2024-05-17 Bruno Haible unistd: Fix compilation error with MSVC in C++ mode. diff --git a/tests/test-getusershell.c b/tests/test-getusershell.c index f009e8902a..ea9d7ac6ed 100644 --- a/tests/test-getusershell.c +++ b/tests/test-getusershell.c @@ -46,11 +46,13 @@ first_pass (void) /* Avoid reallocation. */ shell_count = 16; shells = malloc (shell_count * sizeof (char *)); + ASSERT (shells != NULL); for (; (ptr = getusershell ()); ++i) { - /* Make sure comments are ignored. */ + /* Make sure comments and empty lines are ignored. */ ASSERT (ptr[0] != '#'); + ASSERT (ptr[0] != '\0'); if (i >= shell_count) { shell_count *= 2;