From 9bf839e14b4cde22278c77617b1751c22ced4387 Mon Sep 17 00:00:00 2001 From: Peter Valchev Date: Sun, 4 Aug 2002 23:04:32 +0000 Subject: Handle snprintf(3) returning -1; ok deraadt --- usr.sbin/amd/fsinfo/fsinfo.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/amd/fsinfo/fsinfo.c b/usr.sbin/amd/fsinfo/fsinfo.c index de4923c2f3f..f1829f9026f 100644 --- a/usr.sbin/amd/fsinfo/fsinfo.c +++ b/usr.sbin/amd/fsinfo/fsinfo.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)fsinfo.c 8.1 (Berkeley) 6/6/93 - * $Id: fsinfo.c,v 1.5 2002/06/10 21:07:14 itojun Exp $ + * $Id: fsinfo.c,v 1.6 2002/08/04 23:04:31 pvalchev Exp $ */ #ifndef lint @@ -89,7 +89,8 @@ char *v[]; int ch; int usage = 0; char *iptr = idvbuf; - int iptr_size = sizeof(idvbuf); + int iptr_size = sizeof(idvbuf); + size_t l; while ((ch = getopt(c, v, "a:b:d:e:f:h:m:D:U:I:qv")) != -1) switch (ch) { @@ -131,10 +132,11 @@ char *v[]; verbose = 1; break; case 'I': case 'D': case 'U': - if (snprintf(iptr, iptr_size, "-%c%s ", ch, optarg) >= iptr_size) + l = snprintf(iptr, iptr_size, "-%c%s ", ch, optarg); + if (l >= iptr_size || l < 0) usage++; else { - size_t l = strlen(iptr); + l = strlen(iptr); iptr_size -= l; iptr += strlen(iptr); } -- cgit v1.2.3