diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-14 19:58:33 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-14 19:58:33 +0000 |
commit | fba6017a3ba91f96a647a2f5378b9c9508b860f9 (patch) | |
tree | 95caf22dd47b029d032b535133a378bee41c7e3e /sbin/newfs | |
parent | 4d82c075e7b63f837e4c1533db43dab3ce29467a (diff) |
handle snprintf out of range conditions; otto ok
Diffstat (limited to 'sbin/newfs')
-rw-r--r-- | sbin/newfs/mkfs.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 7d53f37709e..b62854e6824 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.46 2005/01/06 08:57:30 otto Exp $ */ +/* $OpenBSD: mkfs.c,v 1.47 2005/04/14 19:58:32 deraadt Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)mkfs.c 8.3 (Berkeley) 2/3/94"; #else -static char rcsid[] = "$OpenBSD: mkfs.c,v 1.46 2005/01/06 08:57:30 otto Exp $"; +static char rcsid[] = "$OpenBSD: mkfs.c,v 1.47 2005/04/14 19:58:32 deraadt Exp $"; #endif #endif /* not lint */ @@ -665,7 +665,9 @@ next: continue; j = snprintf(tmpbuf, sizeof tmpbuf, " %ld,", fsbtodb(&sblock, cgsblock(&sblock, cylno))); - if (i+j >= width) { + if (j >= sizeof tmpbuf) + j = sizeof tmpbuf - 1; + if (j == -1 || i+j >= width) { printf("\n"); i = 0; } |