com php-src: Simpler overflow check: ext/opcache/zend_acceler ator_module.c

From: Date: Thu, 01 Dec 2016 07:30:02 +0000
Subject: com php-src: Simpler overflow check: ext/opcache/zend_acceler ator_module.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96117@lists.php.net to get a copy of this message
Commit: 003346c450b58a07af9e0061bffb14c287c39be8 Author: Dmitry Stogov <dmitry@zend.com> Thu, 1 Dec 2016 10:30:02 +0300 Parents: d5a2af6d1ce81b4124b690fe86e2e2be0545ae12 Branches: PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=003346c450b58a07af9e0061bffb14c287c39be8 Log: Simpler overflow check Changed paths: M ext/opcache/zend_accelerator_module.c Diff: diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index b6c8e13..cbc3f24 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -107,8 +107,6 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption) #else char *base = (char *) ts_resource(*((int *) mh_arg2)); #endif - zend_long megabyte, overflow; - double dummy; /* keep the compiler happy */ (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage; @@ -132,10 +130,10 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption) ini_entry->value = zend_string_init(new_new_value, 1, 1); } - megabyte = 1024 * 1024; - ZEND_SIGNED_MULTIPLY_LONG(memsize, megabyte, *p, dummy, overflow); - if (UNEXPECTED(overflow)) { + if (UNEXPECTED(memsize > ZEND_ULONG_MAX / (1024 * 1024))) { *p = ZEND_ULONG_MAX; + } else { + *p = memsize * (1024 * 1024); } return SUCCESS; }

« previous php.cvs (#96117) next »