diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2007-09-11 16:31:00 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2007-09-11 16:31:00 +0000 |
commit | a8152da22f218d42cf3e2467c979fd1b1b487943 (patch) | |
tree | 56bcdad1b11232f055be50d69dd3cc079d74a75a /usr.sbin/sliplogin | |
parent | 25679492194cdf74e631b94ff0156ca727ed97f0 (diff) |
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.sbin/sliplogin')
-rw-r--r-- | usr.sbin/sliplogin/sliplogin.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/usr.sbin/sliplogin/sliplogin.c b/usr.sbin/sliplogin/sliplogin.c index 2d5ec497318..d7eb062d032 100644 --- a/usr.sbin/sliplogin/sliplogin.c +++ b/usr.sbin/sliplogin/sliplogin.c @@ -35,7 +35,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)sliplogin.c 5.6 (Berkeley) 3/2/91";*/ -static char rcsid[] = "$Id: sliplogin.c,v 1.26 2007/03/06 03:22:11 ray Exp $"; +static char rcsid[] = "$Id: sliplogin.c,v 1.27 2007/09/11 16:30:59 gilles Exp $"; #endif /* not lint */ /* @@ -120,10 +120,8 @@ findid(char *name) while (fgets(loginargs, sizeof(loginargs), fp)) { if (ferror(fp)) break; - if ((p = strchr(loginargs, '#'))) - *p = '\0'; - if ((p = strchr(loginargs, '\n'))) - *p = '\0'; + loginargs[strcspn(loginargs, "#")] = '\0'; + loginargs[strcspn(loginargs, "\n")] = '\0'; n = sscanf(loginargs, "%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s\n", user, laddr, raddr, mask, slopt[0], slopt[1], slopt[2], slopt[3], slopt[4]); |