diff options
author | Daniel Micay <danielmicay@gmail.com> | 2015-10-31 05:14:45 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015-11-02 16:30:25 -0500 |
commit | f9ecb6bfa1dc9f93a10dad97a158e6b8334c586c (patch) | |
tree | da35380f907cb59e6835eaa733d6643d65715edf /src/mman | |
parent | 36e8b6a28be5d4ffad966386b1e1c0d0dc6ca11a (diff) | |
download | musl-f9ecb6bfa1dc9f93a10dad97a158e6b8334c586c.tar.gz musl-f9ecb6bfa1dc9f93a10dad97a158e6b8334c586c.tar.bz2 musl-f9ecb6bfa1dc9f93a10dad97a158e6b8334c586c.tar.xz musl-f9ecb6bfa1dc9f93a10dad97a158e6b8334c586c.zip |
prevent allocs than PTRDIFF_MAX via mremap
It's quite feasible for this to happen via MREMAP_MAYMOVE.
Diffstat (limited to 'src/mman')
-rw-r--r-- | src/mman/mremap.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mman/mremap.c b/src/mman/mremap.c index 596c45fb..1096ace1 100644 --- a/src/mman/mremap.c +++ b/src/mman/mremap.c @@ -1,5 +1,7 @@ #include <unistd.h> #include <sys/mman.h> +#include <errno.h> +#include <stdint.h> #include <stdarg.h> #include "syscall.h" #include "libc.h" @@ -8,7 +10,12 @@ void *__mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...) { va_list ap; void *new_addr; - + + if (new_len >= PTRDIFF_MAX) { + errno = ENOMEM; + return MAP_FAILED; + } + va_start(ap, flags); new_addr = va_arg(ap, void *); va_end(ap); |