summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-12-08 14:02:48 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-12-08 14:02:48 +0000
commit9a3eda10c4f376bb34bcc10f78d2fd1b8b1e53d5 (patch)
tree0eff35f98f39b661fd110faa0cd6b6e51e205942 /sys/kern
parent1e6de3f4f18390ef34fecf4a5d1ca38677fc0ce4 (diff)
Don't panic for pathological i/o sizes unless minphys() really is
broken. Eliminate an unneeded variable and potential conversion issues in SCIOCCOMMAND code before calling physio. Similar to what NetBSD does. Fixes cdda2wav vs "Billie Holiday - Songs for Distingue Lovers" problem noted by Alexandre Ratchov. Tested by Alexandre. ok marco@ pedro@ deraadt@ mickey@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_physio.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index 25eb36a11a0..5a31a3aa7d4 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_physio.c,v 1.23 2005/11/28 00:14:28 jsg Exp $ */
+/* $OpenBSD: kern_physio.c,v 1.24 2005/12/08 14:02:47 krw Exp $ */
/* $NetBSD: kern_physio.c,v 1.28 1997/05/19 10:43:28 pk Exp $ */
/*-
@@ -124,10 +124,19 @@ physio(void (*strategy)(struct buf *), struct buf *bp, dev_t dev, int flags,
/* [set up the buffer for a maximum-sized transfer] */
bp->b_blkno = btodb(uio->uio_offset);
- bp->b_bcount = iovp->iov_len;
bp->b_data = iovp->iov_base;
/*
+ * Because iov_len is unsigned but b_bcount is signed,
+ * an overflow is possible. Therefore bound to MAXPHYS
+ * before calling minphys.
+ */
+ if (iovp->iov_len > MAXPHYS)
+ bp->b_bcount = MAXPHYS;
+ else
+ bp->b_bcount = iovp->iov_len;
+
+ /*
* [call minphys to bound the tranfer size]
* and remember the amount of data to transfer,
* for later comparison.