Otherwise, the line is invalidly formatted, and we ignore it.
Closes: <https://github.com/shadow-maint/shadow/issues/1036>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
* TTY devices.
*/
+ if (strchr(buf, ':') == NULL)
+ goto next;
+
port.pt_names = ttys;
for (cp = buf, j = 0; j < PORT_TTY; j++) {
port.pt_names[j] = cp;
cp = strpbrk(cp, ":,");
- if (cp == NULL)
- goto next; /* line format error */
-
- if (':' == *cp) { /* end of tty name list */
+ if (':' == *cp) /* end of tty name list */
break;
- }
-
if (',' == *cp) /* end of current tty name */
stpcpy(cp++, "");
}
* The last entry in the list is a NULL pointer.
*/
+ if (strchr(cp, ':') == NULL)
+ goto next;
+
if (':' != *cp) {
port.pt_users = users;
port.pt_users[0] = cp;