summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1996-12-10 14:07:42 +0000
committerbde <bde@FreeBSD.org>1996-12-10 14:07:42 +0000
commit84d7a45e0aa41ae6d51ea47ca968c2ad5463eb55 (patch)
tree06a99d49682ffbfc6d521feae1816d2c07d4a14e /sys
parentfcf606e18750e2398cade575f2af4b55e7066f37 (diff)
downloadFreeBSD-src-84d7a45e0aa41ae6d51ea47ca968c2ad5463eb55.zip
FreeBSD-src-84d7a45e0aa41ae6d51ea47ca968c2ad5463eb55.tar.gz
Give up early for empty partitions. The offset for an empty
partition is 0, which is outside the slice unless the disk is dangerously dedicated. There is little error checking later, and following garbage metadata outside the slice usually caused crashes, Empty 'a' partitions are fairly easy to create by cloning the label for the whole disk. Fixed a missing newline in a related error message.
Diffstat (limited to 'sys')
-rw-r--r--sys/i386/boot/biosboot/disk.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/i386/boot/biosboot/disk.c b/sys/i386/boot/biosboot/disk.c
index 2f5b25c..afde2ce 100644
--- a/sys/i386/boot/biosboot/disk.c
+++ b/sys/i386/boot/biosboot/disk.c
@@ -24,7 +24,7 @@
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:49 rpd
- * $Id: disk.c,v 1.21 1996/10/08 22:25:22 bde Exp $
+ * $Id: disk.c,v 1.22 1996/10/08 22:31:31 bde Exp $
*/
/*
@@ -114,7 +114,7 @@ devopen(void)
disklabel = *dl; /* structure copy (maybe useful later)*/
#endif EMBEDDED_DISKLABEL
if (dl->d_magic != DISKMAGIC) {
- printf("bad disklabel");
+ printf("bad disklabel\n");
return 1;
}
if( (maj == 4) || (maj == 0) || (maj == 1))
@@ -132,8 +132,12 @@ devopen(void)
boff = dl->d_partitions[part].p_offset -
dl->d_partitions[2].p_offset + sector;
- /* This is a good idea for all disks */
bsize = dl->d_partitions[part].p_size;
+ if (bsize == 0) {
+ printf("empty partition\n");
+ return 1;
+ }
+
#ifdef DO_BAD144
do_bad144 = 0;
if (dl->d_flags & D_BADSECT) {
OpenPOWER on IntegriCloud