diff options
| -rw-r--r-- | src/mman/mmap.c | 5 | 
1 files changed, 5 insertions, 0 deletions
| diff --git a/src/mman/mmap.c b/src/mman/mmap.c index e99271f7..b56cff86 100644 --- a/src/mman/mmap.c +++ b/src/mman/mmap.c @@ -1,6 +1,7 @@  #include <unistd.h>  #include <sys/mman.h>  #include <errno.h> +#include <stdint.h>  #include <limits.h>  #include "syscall.h"  #include "libc.h" @@ -20,6 +21,10 @@ void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)  		errno = EINVAL;  		return MAP_FAILED;  	} +	if (len >= PTRDIFF_MAX) { +		errno = ENOMEM; +		return MAP_FAILED; +	}  	if (flags & MAP_FIXED) __vm_lock(-1);  #ifdef SYS_mmap2  	ret = (void *)syscall(SYS_mmap2, start, len, prot, flags, fd, off>>12); | 
