summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorariane <ariane@openbsd.org>2012-04-10 10:30:44 +0000
committerariane <ariane@openbsd.org>2012-04-10 10:30:44 +0000
commit0fd1db7487cc278a669fc78965dd4d69ab8c840a (patch)
tree368be9da008592c26d87205d46f875accb43137c
parentremove unused variable. (diff)
downloadwireguard-openbsd-0fd1db7487cc278a669fc78965dd4d69ab8c840a.tar.xz
wireguard-openbsd-0fd1db7487cc278a669fc78965dd4d69ab8c840a.zip
Return EINVAL on 0-byte mmap invocation.
- Posix rules that a 0-byte mmap must return EINVAL - our allocators are unable to distinguish between free memory and 0 bytes of allocated memory
-rw-r--r--sys/uvm/uvm_mmap.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c
index 6817224e3ce..383e25a092b 100644
--- a/sys/uvm/uvm_mmap.c
+++ b/sys/uvm/uvm_mmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_mmap.c,v 1.88 2012/03/09 13:01:29 ariane Exp $ */
+/* $OpenBSD: uvm_mmap.c,v 1.89 2012/04/10 10:30:44 ariane Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
/*
@@ -362,6 +362,8 @@ sys_mmap(struct proc *p, void *v, register_t *retval)
flags = (flags & ~MAP_COPY) | MAP_PRIVATE;
if ((flags & (MAP_SHARED|MAP_PRIVATE)) == (MAP_SHARED|MAP_PRIVATE))
return (EINVAL);
+ if (size == 0)
+ return (EINVAL);
/*
* align file position and save offset. adjust size.