diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-11 16:31:36 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-11 16:31:36 +0000 |
commit | 5f2fe8ab5c0d2f95d45712ba391f44eccec01d62 (patch) | |
tree | 5f30638a6a2274d722b7a31d1a5df2dd1d90a9ed /usr.bin/file | |
parent | 536b368419c8fbc4f89850985201667b708db831 (diff) |
handle -1 potential case from snprintf too
Diffstat (limited to 'usr.bin/file')
-rw-r--r-- | usr.bin/file/funcs.c | 7 |
1 files changed, 4 insertions, 3 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); |