[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30926 - libmicrohttpd/src/microhttpd
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30926 - libmicrohttpd/src/microhttpd |
Date: |
Thu, 28 Nov 2013 10:16:38 +0100 |
Author: grothoff
Date: 2013-11-28 10:16:38 +0100 (Thu, 28 Nov 2013)
New Revision: 30926
Modified:
libmicrohttpd/src/microhttpd/memorypool.c
Log:
-fix theoretical overflow issue reported by Florian Weimer
Modified: libmicrohttpd/src/microhttpd/memorypool.c
===================================================================
--- libmicrohttpd/src/microhttpd/memorypool.c 2013-11-28 08:59:25 UTC (rev
30925)
+++ libmicrohttpd/src/microhttpd/memorypool.c 2013-11-28 09:16:38 UTC (rev
30926)
@@ -90,7 +90,7 @@
pool = malloc (sizeof (struct MemoryPool));
if (pool == NULL)
- return NULL;
+ return NULL;
#ifdef MAP_ANONYMOUS
if (max <= 32 * 1024)
pool->memory = MAP_FAILED;
@@ -151,12 +151,14 @@
* bytes
*/
void *
-MHD_pool_allocate (struct MemoryPool *pool,
+MHD_pool_allocate (struct MemoryPool *pool,
size_t size, int from_end)
{
void *ret;
size = ROUND_TO_ALIGN (size);
+ if (0 == size)
+ return NULL; /* size too close to SIZE_MAX */
if ((pool->pos + size > pool->end) || (pool->pos + size < pool->pos))
return NULL;
if (from_end == MHD_YES)
@@ -192,13 +194,15 @@
*/
void *
MHD_pool_reallocate (struct MemoryPool *pool,
- void *old,
- size_t old_size,
+ void *old,
+ size_t old_size,
size_t new_size)
{
void *ret;
new_size = ROUND_TO_ALIGN (new_size);
+ if (0 == new_size)
+ return NULL; /* size too close to SIZE_MAX */
if ((pool->end < old_size) || (pool->end < new_size))
return NULL; /* unsatisfiable or bogus request */
@@ -242,8 +246,8 @@
* @return addr new address of @a keep (if it had to change)
*/
void *
-MHD_pool_reset (struct MemoryPool *pool,
- void *keep,
+MHD_pool_reset (struct MemoryPool *pool,
+ void *keep,
size_t size)
{
size = ROUND_TO_ALIGN (size);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30926 - libmicrohttpd/src/microhttpd,
gnunet <=