mirror of
git://git.musl-libc.org/musl
synced 2024-12-24 23:52:48 +00:00
prevent allocs than PTRDIFF_MAX via mremap
It's quite feasible for this to happen via MREMAP_MAYMOVE.
This commit is contained in:
parent
36e8b6a28b
commit
f9ecb6bfa1
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user