summaryrefslogtreecommitdiff
path: root/sys/arch/socppc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2009-06-05 00:41:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2009-06-05 00:41:14 +0000
commitf6c84e623aa405ce40dc494e32099f4d621e8c87 (patch)
tree2dbf83713ba41acc4db134645c897281b2870fb4 /sys/arch/socppc
parent544aa026f27246aa9a6f3fd57a69101b9adbf4fa (diff)
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/arch/socppc')
-rw-r--r--sys/arch/socppc/socppc/disksubr.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/arch/socppc/socppc/disksubr.c b/sys/arch/socppc/socppc/disksubr.c
index 4ecf30af00a..c7c459d0a64 100644
--- a/sys/arch/socppc/socppc/disksubr.c
+++ b/sys/arch/socppc/socppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.6 2009/06/04 21:13:02 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.7 2009/06/05 00:41:13 deraadt Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -106,7 +106,7 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *),
struct disklabel *lp, int *partoffp, int spoofonly)
{
int i, part_cnt, n, hfspartoff = -1;
- u_int hfspartlen;
+ u_int64_t hfspartend;
struct part_map_entry *part;
/* First check for a DPME (HFS) disklabel */
@@ -143,7 +143,7 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *),
if (strcmp(part->pmPartType, PART_TYPE_OPENBSD) == 0) {
hfspartoff = part->pmPyPartStart - LABELSECTOR;
- hfspartlen = part->pmPartBlkCnt;
+ hfspartend = hfspartoff + part->pmPartBlkCnt;
if (partoffp) {
*partoffp = hfspartoff;
return (NULL);
@@ -164,7 +164,8 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *),
}
DL_SETBSTART(lp, hfspartoff);
- DL_SETBEND(lp, hfspartoff + hfspartlen);
+ DL_SETBEND(lp, hfspartend < DL_GETDSIZE(lp) ? hfspartend :
+ DL_GETDSIZE(lp));
}
if (hfspartoff == -1)
@@ -182,7 +183,7 @@ readdpmelabel(struct buf *bp, void (*strat)(struct buf *),
return("disk label I/O error");
return checkdisklabel(bp->b_data + LABELOFFSET, lp, hfspartoff,
- hfspartoff + hfspartlen);
+ hfspartend);
}
/*