com php-src: Fix potential memory issue with USE_ZEND_ALLOC =0: Zend/zend_alloc.c

From: Date: Wed, 07 Sep 2016 20:50:53 +0000
Subject: com php-src: Fix potential memory issue with USE_ZEND_ALLOC =0: Zend/zend_alloc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94691@lists.php.net to get a copy of this message
Commit: 5880428dac00ff9bafccb8c10c7226d6fa1dabbb Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 7 Sep 2016 22:50:53 +0200 Parents: dad793630d5966a9c22f3fcd7f24b7937bd1a36f Branches: PHP-5.6 PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5880428dac00ff9bafccb8c10c7226d6fa1dabbb Log: Fix potential memory issue with USE_ZEND_ALLOC=0 The PHP core and extensions are written with the assumption that memory allocation either succeeds, or the allocator bails out (i.e. the allocator is infallible). Therefore the result of emalloc() and friends are not checked for NULL values. However, with USE_ZEND_ALLOC=0, malloc() and friends are used as allocators, but these are fallible, i.e. they return NULL instead of bailing out if they fail. This easily leads to invalid memory accesses in the following, such as in <https://bugs.php.net/73032>. Some of these cases may constitute exploitable vulnerabilities. Therefore we make the infallible __zend_alloc() and friends the default for USE_ZEND_ALLOC=0. Changed paths: M Zend/zend_alloc.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 105c256..f11a12d 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2726,9 +2726,9 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC) alloc_globals->mm_heap = malloc(sizeof(struct _zend_mm_heap)); memset(alloc_globals->mm_heap, 0, sizeof(struct _zend_mm_heap)); alloc_globals->mm_heap->use_zend_alloc = 0; - alloc_globals->mm_heap->_malloc = malloc; + alloc_globals->mm_heap->_malloc = __zend_malloc; alloc_globals->mm_heap->_free = free; - alloc_globals->mm_heap->_realloc = realloc; + alloc_globals->mm_heap->_realloc = __zend_realloc; } else { alloc_globals->mm_heap = zend_mm_startup(); }

« previous php.cvs (#94691) next »