From: Matthew Dillon Date: Tue, 19 Jun 2007 19:18:20 +0000 (+0000) Subject: Do not blindly allow the block count to overflow. Restrict newfs filesystem X-Git-Tag: v2.0.1~2780 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/5dde079eb1ff4bf42ff55ba51ed42f4665dc20a9 Do not blindly allow the block count to overflow. Restrict newfs filesystem sizes to just under 1TB and report a fatal error if the media is too large. --- diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 277a7089c5..966362f130 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -33,7 +33,7 @@ * @(#) Copyright (c) 1983, 1989, 1993, 1994 The Regents of the University of California. All rights reserved. * @(#)newfs.c 8.13 (Berkeley) 5/1/95 * $FreeBSD: src/sbin/newfs/newfs.c,v 1.30.2.9 2003/05/13 12:03:55 joerg Exp $ - * $DragonFly: src/sbin/newfs/newfs.c,v 1.16 2007/05/20 19:29:21 dillon Exp $ + * $DragonFly: src/sbin/newfs/newfs.c,v 1.17 2007/06/19 19:18:20 dillon Exp $ */ /* @@ -486,6 +486,11 @@ main(int argc, char **argv) if (geom.d_media_blocks == 0 || geom.d_media_size == 0) { fatal("%s: is unavailable", argv[0]); } + printf("%s: media size %6.2fMB\n", + argv[0], geom.d_media_size / 1024.0 / 1024.0); + if (geom.d_media_size / 512 >= 0x80000000ULL) + fatal("%s: media size is too large for newfs to handle", + argv[0]); } havelabel: if (fssize == 0)