diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-06-05 02:38:38 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-06-05 02:38:38 +0000 |
commit | d8edefa5943c6e4c14718b08e96bb6b84856f2e7 (patch) | |
tree | b59258d91c84e69109019b4e996385e7f5dcf3c7 /sys/arch/sparc64 | |
parent | 27424f98f99646fb8b3e4ef11652da62014a7ceb (diff) |
bounds_check_with_label() checks for i/o outside of the partition and
for overwriting the disklabel. Reorder some checks so all copies of
bounds_check_with_label do the checks in the same order. Order picked
by using the currently most popular one. Should be no functional
change.
"If it's boring, commit it" deraadt@
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r-- | sys/arch/sparc64/sparc64/disksubr.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c index 33aeda7dcae..3d81c93090a 100644 --- a/sys/arch/sparc64/sparc64/disksubr.c +++ b/sys/arch/sparc64/sparc64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.28 2007/06/05 00:38:19 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.29 2007/06/05 02:38:37 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */ /* @@ -293,16 +293,6 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, goto bad; } - /* overwriting disk label ? */ - /* XXX should also protect bootstrap in first 8K */ - /* XXX this assumes everything <=LABELSECTOR is label! */ - /* But since LABELSECTOR is 0, that's ok for now. */ - if ((bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= LABELSECTOR) && - ((bp->b_flags & B_READ) == 0) && (wlabel == 0)) { - bp->b_error = EROFS; - goto bad; - } - /* beyond partition? */ if (bp->b_blkno + sz > blockpersec(DL_GETPSIZE(p), lp)) { sz = blockpersec(DL_GETPSIZE(p), lp) - bp->b_blkno; @@ -320,6 +310,16 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, bp->b_bcount = sz << DEV_BSHIFT; } + /* overwriting disk label ? */ + /* XXX should also protect bootstrap in first 8K */ + /* XXX this assumes everything <=LABELSECTOR is label! */ + /* But since LABELSECTOR is 0, that's ok for now. */ + if ((bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= LABELSECTOR) && + ((bp->b_flags & B_READ) == 0) && (wlabel == 0)) { + bp->b_error = EROFS; + goto bad; + } + /* calculate cylinder for disksort to order transfers with */ bp->b_cylinder = (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp)) / lp->d_secpercyl; |