diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-01-15 06:54:52 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-01-15 06:54:52 +0000 |
commit | 98f57d52fc5e80d9d61dcd914c7cc0ed03b44b85 (patch) | |
tree | d1f94135dc76693e74626c9b90a1c0b3fafe1f06 | |
parent | edd3713a770f065ec1d995396af5a81e10a2e78d (diff) |
In uvm_mmap(), check for size wrap to 0, and return ENOMEM in that
case. Do not arbitarily disallow sizes with the high bit set, they
are unsigned. With lotsa help from miod@, test by danh@
ok miod@ millert@ tedu@
-rw-r--r-- | sys/uvm/uvm_mmap.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 44779b5b826..1e6fc9a5564 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.54 2004/05/07 22:47:47 tedu Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.55 2005/01/15 06:54:51 otto Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -421,9 +421,11 @@ sys_mmap(p, v, retval) pageoff = (pos & PAGE_MASK); pos -= pageoff; size += pageoff; /* add offset */ - size = (vsize_t) round_page(size); /* round up */ - if ((ssize_t) size < 0) - return (EINVAL); /* don't allow wrap */ + if (size != 0) { + size = (vsize_t) round_page(size); /* round up */ + if (size == 0) + return (ENOMEM); /* don't allow wrap */ + } /* * now check (MAP_FIXED) or get (!MAP_FIXED) the "addr" |