diff options
author | 2020-01-26 23:06:39 +0000 | |
---|---|---|
committer | 2020-01-26 23:06:39 +0000 | |
commit | d9d2953922bc8914482f52010b7f1cba658bc37e (patch) | |
tree | d3846788e0f1075c9541b634b4883690b3e0dd40 /sys/kern/kern_physio.c | |
parent | Set the default brightness level upon attach. (diff) | |
download | wireguard-openbsd-d9d2953922bc8914482f52010b7f1cba658bc37e.tar.xz wireguard-openbsd-d9d2953922bc8914482f52010b7f1cba658bc37e.zip |
Use long for temporary variables handling b_bcount values in physio().
Add a KASSERTMSG() to check that strategy functions didn't screw
b_resid up too much.
ok beck@ tedu@
Diffstat (limited to 'sys/kern/kern_physio.c')
-rw-r--r-- | sys/kern/kern_physio.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index cbdb94184b7..9549fc4bbaf 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_physio.c,v 1.45 2020/01/25 21:56:49 krw Exp $ */ +/* $OpenBSD: kern_physio.c,v 1.46 2020/01/26 23:06:39 krw Exp $ */ /* $NetBSD: kern_physio.c,v 1.28 1997/05/19 10:43:28 pk Exp $ */ /*- @@ -64,7 +64,8 @@ physio(void (*strategy)(struct buf *), dev_t dev, int flags, { struct iovec *iovp; struct proc *p = curproc; - int error, done, i, s, todo; + long done, todo; + int error, i, s; struct buf *bp; if ((uio->uio_offset % DEV_BSIZE) != 0) @@ -188,6 +189,7 @@ physio(void (*strategy)(struct buf *), dev_t dev, int flags, * [deduct the transfer size from the total number * of data to transfer] */ + KASSERTMSG(bp->b_resid <= LONG_MAX, "strategy broken"); done = bp->b_bcount - bp->b_resid; KASSERTMSG(done >= 0, "strategy broken"); KASSERTMSG(done <= todo, "strategy broken"); |