summaryrefslogtreecommitdiff
path: root/usr.bin/jot
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-04-11 16:31:36 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-04-11 16:31:36 +0000
commit5f2fe8ab5c0d2f95d45712ba391f44eccec01d62 (patch)
tree5f30638a6a2274d722b7a31d1a5df2dd1d90a9ed /usr.bin/jot
parent536b368419c8fbc4f89850985201667b708db831 (diff)
handle -1 potential case from snprintf too
Diffstat (limited to 'usr.bin/jot')
-rw-r--r--usr.bin/jot/jot.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c
index d025ecd58b3..bcfbb92c60c 100644
--- a/usr.bin/jot/jot.c
+++ b/usr.bin/jot/jot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jot.c,v 1.17 2004/01/08 18:50:02 otto Exp $ */
+/* $OpenBSD: jot.c,v 1.18 2005/04/11 16:31:20 deraadt Exp $ */
/* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */
/*-
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)jot.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: jot.c,v 1.17 2004/01/08 18:50:02 otto Exp $";
+static const char rcsid[] = "$OpenBSD: jot.c,v 1.18 2005/04/11 16:31:20 deraadt Exp $";
#endif /* not lint */
/*
@@ -366,7 +366,10 @@ getformat(void)
break;
sz = sizeof(format) - strlen(format) - 1;
if (*p == '\0' && !chardata) {
- if (snprintf(p, sz, "%%.%df", prec) >= (int)sz)
+ int n;
+
+ n = snprintf(p, sz, "%%.%df", prec);
+ if (n == -1 || n >= (int)sz)
errx(1, "-w word too long");
} else if (*p == '\0' && chardata) {
if (strlcpy(p, "%c", sz) >= sz)