summaryrefslogtreecommitdiffstats
path: root/games/factor
diff options
context:
space:
mode:
authorchl <chl@openbsd.org>2007-09-06 20:50:55 +0000
committerchl <chl@openbsd.org>2007-09-06 20:50:55 +0000
commiteb5dffdbef8249ab31f1a4313e3359141c325b30 (patch)
tree406eb7abaad1b5a4a2668e36c3bd165555811bf4 /games/factor
parentsync (diff)
downloadwireguard-openbsd-eb5dffdbef8249ab31f1a4313e3359141c325b30.tar.xz
wireguard-openbsd-eb5dffdbef8249ab31f1a4313e3359141c325b30.zip
use strcspn to properly overwrite '\n' in fgets returned buffer
ok moritz@ ray@
Diffstat (limited to 'games/factor')
-rw-r--r--games/factor/factor.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/games/factor/factor.c b/games/factor/factor.c
index c8b87a62fb3..cb6ede2c892 100644
--- a/games/factor/factor.c
+++ b/games/factor/factor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: factor.c,v 1.16 2006/03/12 00:32:50 deraadt Exp $ */
+/* $OpenBSD: factor.c,v 1.17 2007/09/06 20:50:55 chl Exp $ */
/* $NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $ */
/*
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$OpenBSD: factor.c,v 1.16 2006/03/12 00:32:50 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: factor.c,v 1.17 2007/09/06 20:50:55 chl Exp $";
#endif
#endif /* not lint */
@@ -118,8 +118,7 @@ main(int argc, char *argv[])
err(1, "stdin");
exit (0);
}
- if (*(p = buf + strlen(buf) - 1) == '\n')
- *p = '\0';
+ buf[strcspn(buf, "\n")] = '\0';
for (p = buf; isblank(*p); ++p);
if (*p == '\0')
continue;