apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r800733 - in /apr/apr/branches/0.9.x: CHANGES memory/unix/apr_pools.c
Date Tue, 04 Aug 2009 11:34:13 GMT
Author: wrowe
Date: Tue Aug  4 11:34:13 2009
New Revision: 800733

URL: http://svn.apache.org/viewvc?rev=800733&view=rev
Log:
SECURITY: CVE-2009-2412 (cve.mitre.org)
Fix overflow in pools and rmm, where size alignment was taking place.

Reported by: Matt Lewis <mattlewis@google.com>

memory/unix/apr_pools.c
(allocator_alloc, apr_palloc): Check for overflow after aligning size.
(apr_pcalloc): Drop aligning of size; clearing what the caller asked for should suffice. 

Submitted by: Matt Lewis <mattlewis@google.com>, Sander Striker, William Rowe
Backports: 800730

Modified:
    apr/apr/branches/0.9.x/CHANGES
    apr/apr/branches/0.9.x/memory/unix/apr_pools.c

Modified: apr/apr/branches/0.9.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/CHANGES?rev=800733&r1=800732&r2=800733&view=diff
==============================================================================
--- apr/apr/branches/0.9.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/0.9.x/CHANGES [utf-8] Tue Aug  4 11:34:13 2009
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes with APR 0.9.19
 
+  *) SECURITY: CVE-2009-2412 (cve.mitre.org)
+     Fix overflow in pools and rmm, where size alignment was taking place.
+     [Matt Lewis <mattlewis@google.com>, Sander Striker]
+
 
 
 Changes with APR 0.9.18

Modified: apr/apr/branches/0.9.x/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/memory/unix/apr_pools.c?rev=800733&r1=800732&r2=800733&view=diff
==============================================================================
--- apr/apr/branches/0.9.x/memory/unix/apr_pools.c (original)
+++ apr/apr/branches/0.9.x/memory/unix/apr_pools.c Tue Aug  4 11:34:13 2009
@@ -189,15 +189,19 @@
 }
 
 static APR_INLINE
-apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size)
+apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t in_size)
 {
     apr_memnode_t *node, **ref;
     apr_uint32_t i, index, max_index;
+    apr_size_t size;
 
     /* Round up the block size to the next boundary, but always
      * allocate at least a certain size (MIN_ALLOC).
      */
-    size = APR_ALIGN(size + APR_MEMNODE_T_SIZE, BOUNDARY_SIZE);
+    size = APR_ALIGN(in_size + APR_MEMNODE_T_SIZE, BOUNDARY_SIZE);
+    if (size < in_size) {
+        return NULL;
+    }
     if (size < MIN_ALLOC)
         size = MIN_ALLOC;
 
@@ -625,13 +629,19 @@
  * Memory allocation
  */
 
-APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size)
+APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t in_size)
 {
     apr_memnode_t *active, *node;
     void *mem;
     apr_uint32_t free_index;
+    apr_size_t size;
 
-    size = APR_ALIGN_DEFAULT(size);
+    size = APR_ALIGN_DEFAULT(in_size);
+    if (size < in_size) {
+        if (pool->abort_fn)
+            pool->abort_fn(APR_ENOMEM);
+
+    }
     active = pool->active;
 
     /* If the active node has enough bytes left, use it. */
@@ -696,7 +706,6 @@
 {
     void *mem;
 
-    size = APR_ALIGN_DEFAULT(size);
     if ((mem = apr_palloc(pool, size)) != NULL) {
         memset(mem, 0, size);
     }



Mime
View raw message