File bsc854443-part3.patch of Package libmicrohttpd.28568

From 2c771abfa30534aaa7435281d817f643548aedf7 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Thu, 28 Nov 2013 09:16:38 +0000
Subject: -fix theoretical overflow issue reported by Florian Weimer


diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index 143f10a..f011532 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -151,12 +151,14 @@ MHD_pool_destroy (struct MemoryPool *pool)
  *         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 @@ MHD_pool_allocate (struct MemoryPool *pool,
  */
 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 */
 
-- 
cgit v0.10.2

openSUSE Build Service is sponsored by