aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1998-06-14 10:52:52 +0000
committerBruce Evans <bde@FreeBSD.org>1998-06-14 10:52:52 +0000
commit26d7294956864be539c98fffd8f463a4d8c56c04 (patch)
tree002f46638546463a12d7110f10448bbca9353fcd /sys
parent597035b4db952a9b58494ae267b969eddd0e05a1 (diff)
Notes
Diffstat (limited to 'sys')
-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 c16e636a5517..3e094ee8a6b5 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)