]> granicus.if.org Git - php/commitdiff
Overflow check
authorDmitry Stogov <dmitry@zend.com>
Thu, 17 Nov 2016 10:17:34 +0000 (13:17 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 17 Nov 2016 10:17:34 +0000 (13:17 +0300)
ext/opcache/zend_accelerator_module.c

index a7cf5c386e507cc2dbcc9c4fa3264e0cfc6a0312..481660cb1101d0f4d8d2e17cbcd0a7f0c92125c8 100644 (file)
@@ -107,6 +107,8 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
 #else
        char *base = (char *) ts_resource(*((int *) mh_arg2));
 #endif
+       zend_long overflow;
+       double dummy;
 
        /* keep the compiler happy */
        (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
@@ -130,7 +132,10 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
 
                ini_entry->value = zend_string_init(new_new_value, 1, 1);
        }
-       *p = memsize * (1024 * 1024);
+       ZEND_SIGNED_MULTIPLY_LONG(memsize, 1024 * 1024, *p, dummy, overflow);
+       if (UNEXPECTED(overflow)) {
+               *p = ZEND_ULONG_MAX;
+       }
        return SUCCESS;
 }