summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2009-06-05 00:41:12 +0000
committerderaadt <deraadt@openbsd.org>2009-06-05 00:41:12 +0000
commit2c73cf1f4573132b641f38884fb00c166e4699b0 (patch)
tree5b73e26ca193337c746595e109cd8448279b2661 /sys/kern/subr_disk.c
parentThe names for p_flags bits had fallen out of date (diff)
downloadwireguard-openbsd-2c73cf1f4573132b641f38884fb00c166e4699b0.tar.xz
wireguard-openbsd-2c73cf1f4573132b641f38884fb00c166e4699b0.zip
Clamp the ending bound to the size of the disk. This makes disklabel -A
still do the right thing if the MBR has a lie in it
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r--sys/kern/subr_disk.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 435db496073..2508c186ce1 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.92 2009/06/04 21:13:02 deraadt Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.93 2009/06/05 00:41:13 deraadt Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -361,7 +361,7 @@ checkdisklabel(void *rlp, struct disklabel *lp,
DL_SETPSIZE(&lp->d_partitions[RAW_PART], disksize);
DL_SETPOFFSET(&lp->d_partitions[RAW_PART], 0);
DL_SETBSTART(lp, boundstart);
- DL_SETBEND(lp, boundend);
+ DL_SETBEND(lp, boundend < DL_GETDSIZE(lp) ? boundend : DL_GETDSIZE(lp));
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
@@ -576,7 +576,7 @@ donot:
}
notfat:
DL_SETBSTART(lp, dospartoff);
- DL_SETBEND(lp, dospartend);
+ DL_SETBEND(lp, dospartend < DL_GETDSIZE(lp) ? dospartend : DL_GETDSIZE(lp));
/* record the OpenBSD partition's placement for the caller */
if (partoffp)