projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
36e8b6a
)
prevent allocs than PTRDIFF_MAX via mremap
author
Daniel Micay
<danielmicay@gmail.com>
Sat, 31 Oct 2015 09:14:45 +0000
(
05:14
-0400)
committer
Rich Felker
<dalias@aerifal.cx>
Mon, 2 Nov 2015 21:30:25 +0000
(16:30 -0500)
It's quite feasible for this to happen via MREMAP_MAYMOVE.
src/mman/mremap.c
patch
|
blob
|
history
diff --git
a/src/mman/mremap.c
b/src/mman/mremap.c
index 596c45fbded8426fc0ef19e03c3de5943ae629d3..1096ace100d0d3ddd285a399f82028a864f3bc0c 100644
(file)
--- 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);