diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2002-08-04 23:04:32 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2002-08-04 23:04:32 +0000 |
commit | 9bf839e14b4cde22278c77617b1751c22ced4387 (patch) | |
tree | 25962ec843f2d1cdf5c3e7e5fd402e2adfe61086 /usr.sbin/amd | |
parent | 0591c8c712601ae6a1b02b441e1f985180cc4714 (diff) |
Handle snprintf(3) returning -1; ok deraadt
Diffstat (limited to 'usr.sbin/amd')
-rw-r--r-- | usr.sbin/amd/fsinfo/fsinfo.c | 10 |
1 files changed, 6 insertions, 4 deletions
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); } |