]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/port.c: Use STRSEP2LS() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Fri, 6 Dec 2024 21:03:48 +0000 (22:03 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Sat, 7 Jun 2025 14:52:03 +0000 (16:52 +0200)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/port.c

index 7e1a7b70e7704cae015cde27f14f9eb158392db2..26f8c2080b6ff8ba6e8743fd9501d91d1a520ed0 100644 (file)
@@ -22,6 +22,7 @@
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strtok/stpsep.h"
+#include "string/strtok/strsep2ls.h"
 
 
 static FILE *ports;
@@ -160,13 +161,7 @@ next:
                goto next;
 
        port.pt_names = ttys;
-       for (j = 0; j < PORT_TTY; j++) {
-               port.pt_names[j] = strsep(&cp, ",");
-               if (cp == NULL)
-                       break;
-       }
-       port.pt_names[j] = NULL;
-       if (cp != NULL)
+       if (STRSEP2LS(cp, ",", ttys) == -1)
                goto next;
 
        /*
@@ -181,13 +176,7 @@ next:
                goto next;
 
        port.pt_users = users;
-       for (j = 0; j < PORT_IDS; j++) {
-               port.pt_users[j] = strsep(&cp, ",");
-               if (cp == NULL)
-                       break;
-       }
-       port.pt_users[j] = NULL;
-       if (cp != NULL)
+       if (STRSEP2LS(cp, ",", users) == -1)
                goto next;
 
        /*