|
|
147e83 |
diff --git glibc-2.17-c758a686/malloc/malloc.c glibc-2.17-c758a686/malloc/malloc.c
|
|
|
147e83 |
index 3148c5f..f7718a9 100644
|
|
|
147e83 |
--- glibc-2.17-c758a686/malloc/malloc.c
|
|
|
147e83 |
+++ glibc-2.17-c758a686/malloc/malloc.c
|
|
|
147e83 |
@@ -3015,6 +3015,13 @@ __libc_memalign(size_t alignment, size_t bytes)
|
|
|
147e83 |
/* Otherwise, ensure that it is at least a minimum chunk size */
|
|
|
147e83 |
if (alignment < MINSIZE) alignment = MINSIZE;
|
|
|
147e83 |
|
|
|
147e83 |
+ /* Check for overflow. */
|
|
|
147e83 |
+ if (bytes > SIZE_MAX - alignment - MINSIZE)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ __set_errno (ENOMEM);
|
|
|
147e83 |
+ return 0;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
arena_get(ar_ptr, bytes + alignment + MINSIZE);
|
|
|
147e83 |
if(!ar_ptr)
|
|
|
147e83 |
return 0;
|
|
|
147e83 |
@@ -3046,6 +3046,13 @@ __libc_valloc(size_t bytes)
|
|
|
147e83 |
|
|
|
147e83 |
size_t pagesz = GLRO(dl_pagesize);
|
|
|
147e83 |
|
|
|
147e83 |
+ /* Check for overflow. */
|
|
|
147e83 |
+ if (bytes > SIZE_MAX - pagesz - MINSIZE)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ __set_errno (ENOMEM);
|
|
|
147e83 |
+ return 0;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
__malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t,
|
|
|
147e83 |
const __malloc_ptr_t)) =
|
|
|
147e83 |
force_reg (__memalign_hook);
|
|
|
147e83 |
@@ -3082,6 +3082,13 @@ __libc_pvalloc(size_t bytes)
|
|
|
147e83 |
size_t page_mask = GLRO(dl_pagesize) - 1;
|
|
|
147e83 |
size_t rounded_bytes = (bytes + page_mask) & ~(page_mask);
|
|
|
147e83 |
|
|
|
147e83 |
+ /* Check for overflow. */
|
|
|
147e83 |
+ if (bytes > SIZE_MAX - 2*pagesz - MINSIZE)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ __set_errno (ENOMEM);
|
|
|
147e83 |
+ return 0;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
__malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t,
|
|
|
147e83 |
const __malloc_ptr_t)) =
|
|
|
147e83 |
force_reg (__memalign_hook);
|