summaryrefslogtreecommitdiff
path: root/usr.bin/gzsig
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2007-09-11 15:47:18 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2007-09-11 15:47:18 +0000
commita8ba60ecf20c221bd24ff666339eb5edcbbbac33 (patch)
tree650532cc79cb8294b5e7739a5b61676601594950 /usr.bin/gzsig
parentd0c98e555e46b02b8df61047ae1c820859b23e93 (diff)
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.bin/gzsig')
-rw-r--r--usr.bin/gzsig/sign.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/gzsig/sign.c b/usr.bin/gzsig/sign.c
index dc073fc7afb..795add21f0f 100644
--- a/usr.bin/gzsig/sign.c
+++ b/usr.bin/gzsig/sign.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sign.c,v 1.7 2006/04/17 09:36:56 moritz Exp $ */
+/* $OpenBSD: sign.c,v 1.8 2007/09/11 15:47:17 gilles Exp $ */
/*
* sign.c
@@ -200,8 +200,7 @@ sign_passwd_cb(char *buf, int size, int rwflag, void *u)
if (fgets(buf, size, f) == NULL)
err(1, "fgets(%.64s)", passphrase_file);
fclose(f);
- if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0';
+ buf[strcspn(buf, "\n")] = '\0';
} else {
p = getpass("Enter passphrase: ");
if (strlcpy(buf, p, size) >= size)