X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fmman%2Fmmap.c;h=b56cff86b6da4b9265b3a1350fb4ea54c0f46015;hp=e99271f7e5dd7092cf5b84201906527425151ed9;hb=3cd6f5229f079f892411e82fce3fe15c78eef4d8;hpb=b17c75a4d539d7ec5b81cc7ce7ce6b065a87e7a6 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 #include #include +#include #include #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);