You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
diff --git glibc-2.17-c758a686/malloc/malloc.c glibc-2.17-c758a686/malloc/malloc.c |
|
index 3148c5f..f7718a9 100644 |
|
--- glibc-2.17-c758a686/malloc/malloc.c |
|
+++ glibc-2.17-c758a686/malloc/malloc.c |
|
@@ -3015,6 +3015,13 @@ __libc_memalign(size_t alignment, size_t bytes) |
|
/* Otherwise, ensure that it is at least a minimum chunk size */ |
|
if (alignment < MINSIZE) alignment = MINSIZE; |
|
|
|
+ /* Check for overflow. */ |
|
+ if (bytes > SIZE_MAX - alignment - MINSIZE) |
|
+ { |
|
+ __set_errno (ENOMEM); |
|
+ return 0; |
|
+ } |
|
+ |
|
arena_get(ar_ptr, bytes + alignment + MINSIZE); |
|
if(!ar_ptr) |
|
return 0; |
|
@@ -3046,6 +3046,13 @@ __libc_valloc(size_t bytes) |
|
|
|
size_t pagesz = GLRO(dl_pagesize); |
|
|
|
+ /* Check for overflow. */ |
|
+ if (bytes > SIZE_MAX - pagesz - MINSIZE) |
|
+ { |
|
+ __set_errno (ENOMEM); |
|
+ return 0; |
|
+ } |
|
+ |
|
__malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t, |
|
const __malloc_ptr_t)) = |
|
force_reg (__memalign_hook); |
|
@@ -3082,6 +3082,13 @@ __libc_pvalloc(size_t bytes) |
|
size_t page_mask = GLRO(dl_pagesize) - 1; |
|
size_t rounded_bytes = (bytes + page_mask) & ~(page_mask); |
|
|
|
+ /* Check for overflow. */ |
|
+ if (bytes > SIZE_MAX - 2*pagesz - MINSIZE) |
|
+ { |
|
+ __set_errno (ENOMEM); |
|
+ return 0; |
|
+ } |
|
+ |
|
__malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t, |
|
const __malloc_ptr_t)) = |
|
force_reg (__memalign_hook);
|
|
|