]> Savannah Git Hosting - gnulib.git/commitdiff
getusershell tests: Fail if empty lines are returned.
authorCollin Funk <collin.funk1@gmail.com>
Sat, 18 May 2024 01:53:51 +0000 (18:53 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 18 May 2024 01:53:51 +0000 (18:53 -0700)
* 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.

ChangeLog
tests/test-getusershell.c

index 888ab7fdd76c759e3106d5088918a37840bb257f..e1a840eb0487b035ac2bc839b74cf165d13e6bae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-05-17  Collin Funk  <collin.funk1@gmail.com>
+
+       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  <bruno@clisp.org>
 
        unistd: Fix compilation error with MSVC in C++ mode.
index f009e8902ab967ca043c790598735d7fc4b13cd8..ea9d7ac6ed993bbf999b9f24c6e63551c64cad71 100644 (file)
@@ -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;