diff --git a/lib/port.c b/lib/port.c index bda19444..6f054932 100644 --- a/lib/port.c +++ b/lib/port.c @@ -144,23 +144,19 @@ next: * 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 */ - *cp++ = '\0'; - } + if (',' == *cp) /* end of current tty name */ + stpcpy(cp++, ""); } - *cp = '\0'; - cp++; + stpcpy(cp++, ""); port.pt_names[j] = NULL; /* @@ -170,6 +166,9 @@ next: * 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;