Re: com php-src: Use zend_string_safe_alloc: ext/gmp/gmp.c ext/standard/string.c ext/standard/var_unserializer.c ext/standard/var_unserializer.re
| From: | Matt Wilmas | Date: | Wed, 27 Apr 2016 09:25:30 +0000 |
| Subject: | Re: com php-src: Use zend_string_safe_alloc: ext/gmp/gmp.c ext/standard/string.c ext/standard/var_unserializer.c ext/standard/var_unserializer.re | ||
| References: | 1 2 3 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-91863@lists.php.net to get a copy of this message | ||
Hi Stas, Nikita, Dmitry, et al.,
----- Original Message -----
From: "Stanislav Malyshev"
Sent: Wednesday, April 27, 2016
Hi!In these 1 * n + 0 cases, certainly don't need the useless safe_* multiply and add stuff. Just a simple check: if (UNEXPECTED(len > SIZE_MAX - ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(0)))) /* Error */ Even if added to all cases, should be basically free, except that it does make code a bit larger...This looks odd. Shouldn't we fix zend_string_alloc to check for overflow, so this is covered for everything?That was my initial proposal too, but Dmitry seems to be reluctant to do that due to possible performance implications (we use zend_string_alloc a lot, of course).
-- Stas Malyshev smalyshev@gmail.com- Matt