summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2007-12-16 20:57:17 +0000
committerotto <otto@openbsd.org>2007-12-16 20:57:17 +0000
commitd8a9cb1f284936381239819616ea18dc1569f53d (patch)
tree7a685953be359140d7cc4c90ba28509f180e7b96 /sys/kern/subr_disk.c
parentUpdates from master repo: (diff)
downloadwireguard-openbsd-d8a9cb1f284936381239819616ea18dc1569f53d.tar.xz
wireguard-openbsd-d8a9cb1f284936381239819616ea18dc1569f53d.zip
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;