From 10a075fbd5edd784650e66c893c9037ee4290553 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Tue, 18 Oct 2016 09:28:18 +0900 Subject: [PATCH 1/3] Update NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 1136fc03703..12350672af6 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ PHP NEWS name to namespace). (Nikita) . Fixed bug #66862 ((Sub-)Namespaces unexpected behaviour). (Nikita) . Fix pthreads detection when cross-compiling (ffontaine) + . Fixed bug #73215 (uniqid() should use better random source). (Yasuo) - GD: . Fixed bug #73213 (Integer overflow in imageline() with antialiasing). (cmb) From 8c74be0c52d8d1d9c7304385b3c9c7a1bfb8b873 Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Tue, 18 Oct 2016 11:30:19 +0100 Subject: [PATCH 2/3] Revert "Fix bug #47890 #73215 uniqid() should use better random source" This reverts commit 48f1a17886d874dc90867c669481804de90509e8. --- ext/standard/uniqid.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c index 207cf01cb86..f429e6d4a0e 100644 --- a/ext/standard/uniqid.c +++ b/ext/standard/uniqid.c @@ -35,11 +35,9 @@ #include #endif -#include "php_random.h" +#include "php_lcg.h" #include "uniqid.h" -#define PHP_UNIQID_ENTROPY_LEN 10 - /* {{{ proto string uniqid([string prefix [, bool more_entropy]]) Generates a unique ID */ #ifdef HAVE_GETTIMEOFDAY @@ -79,22 +77,7 @@ PHP_FUNCTION(uniqid) * digits for usecs. */ if (more_entropy) { - int i; - unsigned char c, entropy[PHP_UNIQID_ENTROPY_LEN+1]; - - for(i = 0; i < PHP_UNIQID_ENTROPY_LEN;) { - php_random_bytes_throw(&c, sizeof(c)); - /* Avoid modulo bias */ - if (c > 249) { - continue; - } - entropy[i] = c % 10 + '0'; - i++; - } - /* Set . for compatibility */ - entropy[1] = '.'; - entropy[PHP_UNIQID_ENTROPY_LEN] = '\0'; - uniqid = strpprintf(0, "%s%08x%05x%s", prefix, sec, usec, entropy); + uniqid = strpprintf(0, "%s%08x%05x%.8F", prefix, sec, usec, php_combined_lcg() * 10); } else { uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec); } From 6558559bcc1cd24e3639e4a215e9d546ee05fc48 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Oct 2016 14:48:01 +0300 Subject: [PATCH 3/3] Fixed bug #73337 (try/catch not working with two exceptions inside a same operation) --- NEWS | 4 ++++ Zend/tests/bug73337.phpt | 12 ++++++++++++ Zend/zend_execute_API.c | 3 +++ 3 files changed, 19 insertions(+) create mode 100644 Zend/tests/bug73337.phpt diff --git a/NEWS b/NEWS index 6db7d29a1a2..fc2e52c11e0 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2016, PHP 5.6.28 +- Core: + . Fixed bug #73337 (try/catch not working with two exceptions inside a same + operation). (Dmitry) + -GD: . Fixed bug #73213 (Integer overflow in imageline() with antialiasing). (cmb) . Fixed bug #73272 (imagescale() is not affected by, but affects diff --git a/Zend/tests/bug73337.phpt b/Zend/tests/bug73337.phpt new file mode 100644 index 00000000000..9eff18e6433 --- /dev/null +++ b/Zend/tests/bug73337.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #73337 (try/catch not working with two exceptions inside a same operation) +--FILE-- + +--EXPECTF-- +Notice: Object of class d could not be converted to int in %sbug73337.php on line 3 + +Notice: Object of class d could not be converted to int in %sbug73337.php on line 3 +Exception properly caught diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 7eeece37d00..bf754d25df2 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -826,7 +826,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) { *fci->retval_ptr_ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC); } else { + const zend_op *current_opline_before_exception = EG(opline_before_exception); + zend_execute(EG(active_op_array) TSRMLS_CC); + EG(opline_before_exception) = current_opline_before_exception; } if (!fci->symbol_table && EG(active_symbol_table)) {