diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-08-12 07:53:51 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-08-12 07:53:51 +0000 |
commit | 15300e846f10138870406bd9b65ea769dbeb0e8f (patch) | |
tree | 42ccffd698a89b4636d9c374b7c6853807db14b8 /sbin/newfs | |
parent | 090846a43ee80a1044510b2fc185bd2a16728658 (diff) |
Prevent core dump on large block sizes by checking block size against
MAXBSIZE. ok millert@
Diffstat (limited to 'sbin/newfs')
-rw-r--r-- | sbin/newfs/mkfs.c | 8 | ||||
-rw-r--r-- | sbin/newfs/newfs.c | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 26435c2b82d..91779e7c7ae 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.42 2004/07/06 07:31:59 otto Exp $ */ +/* $OpenBSD: mkfs.c,v 1.43 2004/08/12 07:53:50 otto 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.42 2004/07/06 07:31:59 otto Exp $"; +static char rcsid[] = "$OpenBSD: mkfs.c,v 1.43 2004/08/12 07:53:50 otto Exp $"; #endif #endif /* not lint */ @@ -247,6 +247,10 @@ recalc: errx(19, "block size %d is too small, minimum is %d", sblock.fs_bsize, MINBSIZE); } + if (sblock.fs_bsize > MAXBSIZE) { + errx(19, "block size %d is too large, maximum is %d", + sblock.fs_bsize, MAXBSIZE); + } if (sblock.fs_bsize < sblock.fs_fsize) { errx(20, "block size (%d) cannot be smaller than fragment size (%d)", sblock.fs_bsize, sblock.fs_fsize); diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 1209d60e8e3..6f6643daa21 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.49 2004/07/02 15:48:36 otto Exp $ */ +/* $OpenBSD: newfs.c,v 1.50 2004/08/12 07:53:50 otto Exp $ */ /* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)newfs.c 8.8 (Berkeley) 4/18/94"; #else -static char rcsid[] = "$OpenBSD: newfs.c,v 1.49 2004/07/02 15:48:36 otto Exp $"; +static char rcsid[] = "$OpenBSD: newfs.c,v 1.50 2004/08/12 07:53:50 otto Exp $"; #endif #endif /* not lint */ @@ -255,7 +255,7 @@ main(int argc, char *argv[]) optarg); break; case 'b': - if ((bsize = atoi(optarg)) < MINBSIZE) + if ((bsize = atoi(optarg)) < 0) fatal("%s: bad block size", optarg); break; case 'c': |