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/config | |
parent | 25679492194cdf74e631b94ff0156ca727ed97f0 (diff) |
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/misc.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/usr.sbin/config/misc.c b/usr.sbin/config/misc.c index da9c9f69b48..4eea2190c64 100644 --- a/usr.sbin/config/misc.c +++ b/usr.sbin/config/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.6 2006/12/06 05:05:16 ray Exp $ */ +/* $OpenBSD: misc.c,v 1.7 2007/09/11 16:30:59 gilles Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -26,7 +26,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: misc.c,v 1.6 2006/12/06 05:05:16 ray Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.7 2007/09/11 16:30:59 gilles Exp $"; #endif #include <sys/types.h> @@ -48,8 +48,7 @@ ask_cmd(cmd_t *cmd) /* Get input */ if (fgets(lbuf, sizeof lbuf, stdin) == NULL) errx(1, "eof"); - if ((cp = strchr(lbuf, '\n')) != NULL) - *cp = '\0'; + lbuf[strcspn(lbuf, "\n")] = '\0'; if (verbose) printf("%s\n", lbuf); |