summaryrefslogtreecommitdiff
path: root/sys/kern/subr_disk.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2009-02-09 20:00:49 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2009-02-09 20:00:49 +0000
commit0b30c4960dcd7ee59fca6513a4b5b04ddb61710f (patch)
tree68d19af242abd8c2835c7155406069112f015bcf /sys/kern/subr_disk.c
parentdba16114235e5c0afee06367cd75f83762035d62 (diff)
two more consistency checks for a disklabel, to prevent havoc later
on; prompted by Thorsten Glaser; ok miod@ krw@
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r--sys/kern/subr_disk.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 00250e62985..83eb949a0f8 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.83 2008/11/21 23:51:30 krw Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.84 2009/02/09 20:00:48 otto Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -229,9 +229,13 @@ checkdisklabel(void *rlp, struct disklabel *lp)
if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC)
msg = "no disk label";
else if (dlp->d_npartitions > MAXPARTITIONS)
- msg = "unreasonable partition count";
+ msg = "invalid label, partition count > MAXPARTITIONS";
+ else if (dlp->d_secpercyl == 0)
+ msg = "invalid label, d_secpercyl == 0";
+ else if (dlp->d_secsize == 0)
+ msg = "invalid label, d_secsize == 0";
else if (dkcksum(dlp) != 0)
- msg = "disk label corrupted";
+ msg = "invalid label, incorrect checksum";
if (msg) {
u_int16_t *start, *end, sum = 0;