diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-03 17:16:33 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-03 17:16:33 +0000 |
commit | 9f1764cc8fdb2249884951073320e0484066102b (patch) | |
tree | ef214edbbef0c8205b4dabfaf76aafa77582a9c1 /usr.bin/chpass | |
parent | 7553e7f12279689d841e65272aa9b6eb135904d0 (diff) |
Deal with files w/o a trailing newline before EOF. Found by mpech@
Diffstat (limited to 'usr.bin/chpass')
-rw-r--r-- | usr.bin/chpass/edit.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c index 63dee16093a..2e914d8daf2 100644 --- a/usr.bin/chpass/edit.c +++ b/usr.bin/chpass/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.25 2003/02/07 23:28:18 millert Exp $ */ +/* $OpenBSD: edit.c,v 1.26 2003/04/03 17:16:32 millert Exp $ */ /* $NetBSD: edit.c,v 1.6 1996/05/15 21:50:45 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: edit.c,v 1.25 2003/02/07 23:28:18 millert Exp $"; +static char rcsid[] = "$OpenBSD: edit.c,v 1.26 2003/04/03 17:16:32 millert Exp $"; #endif #endif /* not lint */ @@ -169,11 +169,12 @@ verify(tempname, pw) line++; if (!buf[0] || buf[0] == '#') continue; - if (!(p = strchr(buf, '\n'))) { + if ((p = strchr(buf, '\n')) != NULL) + *p = '\0'; + else if (!feof(fp)) { warnx("line %u too long", line); goto bad; } - *p = '\0'; for (ep = list;; ++ep) { if (!ep->prompt) { warnx("unrecognized field on line %u", line); |