summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa/ctx.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-06-14 10:52:52 +0000
committerbde <bde@FreeBSD.org>1998-06-14 10:52:52 +0000
commitf38597edce3bcec6507debd9e0984d84cd2a8874 (patch)
tree4c84836b202d14064a6f7ec020201ef0ab8c8c5c /sys/i386/isa/ctx.c
parent3a45fc35f91e4e30fc366f0ea40376b137c13873 (diff)
downloadFreeBSD-src-f38597edce3bcec6507debd9e0984d84cd2a8874.zip
FreeBSD-src-f38597edce3bcec6507debd9e0984d84cd2a8874.tar.gz
Avoid 64-bit divisions and modulos. Fixed related overflows for weird
args. This driver should not be used, since it calls uiomove() with interrupts disabled.
Diffstat (limited to 'sys/i386/isa/ctx.c')
-rw-r--r--sys/i386/isa/ctx.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/sys/i386/isa/ctx.c b/sys/i386/isa/ctx.c
index c16e636..3e094ee 100644
--- a/sys/i386/isa/ctx.c
+++ b/sys/i386/isa/ctx.c
@@ -8,7 +8,7 @@
* of this software, nor does the author assume any responsibility
* for damages incurred with its use.
*
- * $Id: ctx.c,v 1.26 1998/01/24 02:54:17 eivind Exp $
+ * $Id: ctx.c,v 1.27 1998/06/07 17:10:15 dfr Exp $
*/
/*
@@ -281,8 +281,13 @@ ctxwrite(dev_t dev, struct uio * uio, int ioflag)
unit = UNIT(minor(dev));
sr = &(ctx_sr[unit]);
- page = uio->uio_offset / PAGESIZE;
- offset = uio->uio_offset % PAGESIZE;
+ if (uio->uio_offset < 0)
+ return (EINVAL);
+ if (uio->uio_offset >= 4 * PAGESIZE)
+ page = 4; /* EOF */
+ else
+ page = (u_int)uio->uio_offset / PAGESIZE;
+ offset = (u_int)uio->uio_offset % PAGESIZE;
count = min(uio->uio_resid, PAGESIZE - offset);
while ((page >= 0) && (page <= 3) && (count > 0)) {
sr->cp0 &= ~3;
@@ -306,8 +311,8 @@ ctxwrite(dev_t dev, struct uio * uio, int ioflag)
outb(sr->iobase + ctx_cp1, sr->cp1);
enable_intr();
- page = uio->uio_offset / PAGESIZE;
- offset = uio->uio_offset % PAGESIZE;
+ page = (u_int)uio->uio_offset / PAGESIZE;
+ offset = (u_int)uio->uio_offset % PAGESIZE;
count = min(uio->uio_resid, PAGESIZE - offset);
}
if (uio->uio_resid > 0)
@@ -326,8 +331,13 @@ ctxread(dev_t dev, struct uio * uio, int ioflag)
unit = UNIT(minor(dev));
sr = &(ctx_sr[unit]);
- page = uio->uio_offset / PAGESIZE;
- offset = uio->uio_offset % PAGESIZE;
+ if (uio->uio_offset < 0)
+ return (EINVAL);
+ if (uio->uio_offset >= 4 * PAGESIZE)
+ page = 4; /* EOF */
+ else
+ page = (u_int)uio->uio_offset / PAGESIZE;
+ offset = (u_int)uio->uio_offset % PAGESIZE;
count = min(uio->uio_resid, PAGESIZE - offset);
while ((page >= 0) && (page <= 3) && (count > 0)) {
sr->cp0 &= ~3;
@@ -349,8 +359,8 @@ ctxread(dev_t dev, struct uio * uio, int ioflag)
outb(sr->iobase + ctx_cp1, sr->cp1);
enable_intr();
- page = uio->uio_offset / PAGESIZE;
- offset = uio->uio_offset % PAGESIZE;
+ page = (u_int)uio->uio_offset / PAGESIZE;
+ offset = (u_int)uio->uio_offset % PAGESIZE;
count = min(uio->uio_resid, PAGESIZE - offset);
}
if (uio->uio_resid > 0)
OpenPOWER on IntegriCloud