From 929931ed6cecd7dca8898485a9c5038c99115eda Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 2 May 1996 15:41:16 +0000 Subject: (map): Fix fencepost error in check of current mapping window. Request round_page (LEN) bytes in io_read to avoid many small reads. --- exec/exec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'exec/exec.c') diff --git a/exec/exec.c b/exec/exec.c index 678de109..1734c5c3 100644 --- a/exec/exec.c +++ b/exec/exec.c @@ -428,7 +428,7 @@ map (struct execdata *e, off_t posn, size_t len) size_t offset; if ((f->__target & ~(f->__bufsize - 1)) == (posn & ~(f->__bufsize - 1)) && - f->__buffer + (posn + len - f->__target) <= f->__get_limit) + f->__buffer + (posn + len - f->__target) < f->__get_limit) /* The current mapping window covers it. */ offset = posn & (f->__bufsize - 1); else if (e->filemap == MACH_PORT_NULL) @@ -436,7 +436,8 @@ map (struct execdata *e, off_t posn, size_t len) /* No mapping for the file. Read the data by RPC. */ char *buffer = f->__buffer; mach_msg_type_number_t nread = f->__bufsize; - e->error = io_read (e->file, &buffer, &nread, posn, len); + /* Read as much as we can get into the buffer right now. */ + e->error = io_read (e->file, &buffer, &nread, posn, round_page (len)); if (e->error) { errno = e->error; -- cgit v1.2.3