diff options
author | 2005-12-08 14:02:47 +0000 | |
---|---|---|
committer | 2005-12-08 14:02:47 +0000 | |
commit | 74444e3eba892d25a1194c1332f0ec6ac48ab18e (patch) | |
tree | c7dc9fc98ca4eb60f539045f66e00350eeeecef5 /sys/kern/kern_physio.c | |
parent | Avoid sign extend by casting to u_char *; from NetBSD via Guy Harris. (diff) | |
download | wireguard-openbsd-74444e3eba892d25a1194c1332f0ec6ac48ab18e.tar.xz wireguard-openbsd-74444e3eba892d25a1194c1332f0ec6ac48ab18e.zip |
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/kern_physio.c')
-rw-r--r-- | sys/kern/kern_physio.c | 13 |
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. |