diff options
-rw-r--r-- | usr.bin/file/funcs.c | 7 | ||||
-rw-r--r-- | usr.bin/jot/jot.c | 9 |
2 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/file/funcs.c b/usr.bin/file/funcs.c index 32b290c2f96..00a6070c4cb 100644 --- a/usr.bin/file/funcs.c +++ b/usr.bin/file/funcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: funcs.c,v 1.2 2004/05/19 02:36:26 tedu Exp $ */ +/* $OpenBSD: funcs.c,v 1.3 2005/04/11 16:31:35 deraadt Exp $ */ /* * Copyright (c) Christos Zoulas 2003. * All Rights Reserved. @@ -35,7 +35,7 @@ #include <ctype.h> #ifndef lint -FILE_RCSID("@(#)$Id: funcs.c,v 1.2 2004/05/19 02:36:26 tedu Exp $") +FILE_RCSID("@(#)$Id: funcs.c,v 1.3 2005/04/11 16:31:35 deraadt Exp $") #endif /* lint */ /* * Like printf, only we print to a buffer and advance it. @@ -49,7 +49,8 @@ file_printf(struct magic_set *ms, const char *fmt, ...) va_start(ap, fmt); - if ((len = vsnprintf(ms->o.ptr, ms->o.len, fmt, ap)) >= ms->o.len) { + len = vsnprintf(ms->o.ptr, ms->o.len, fmt, ap); + if (len == -1 || len >= ms->o.len) { va_end(ap); if ((buf = realloc(ms->o.buf, len + 1024)) == NULL) { file_oomem(ms); 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) |