summaryrefslogtreecommitdiff
path: root/sys/kern/subr_disk.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-12-16 20:57:18 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-12-16 20:57:18 +0000
commitcea912f1d50bba2f837b3a5d588cc238c779d84e (patch)
tree3561d83972fc353c6ffbc039cbe3ae7f936bb7fd /sys/kern/subr_disk.c
parentf4e28a5b130c27ce8fced9f84bbd4aa5e1f11700 (diff)
panic on negative blkno or size; ok kettenis@ deraadt@
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r--sys/kern/subr_disk.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 52f0c4df054..2bf6f11b7e0 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.66 2007/11/09 11:32:57 jsing Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.67 2007/12/16 20:57:17 otto Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -615,6 +615,9 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
if (lp->d_secpercyl == 0)
goto bad;
+ if (bp->b_blkno < 0 || sz < 0)
+ panic("bounds_check_with_label %lld %lld\n", bp->b_blkno, sz);
+
/* beyond partition? */
if (bp->b_blkno + sz > blockpersec(DL_GETPSIZE(p), lp)) {
sz = blockpersec(DL_GETPSIZE(p), lp) - bp->b_blkno;