Merge branch 'PHP-7.1'

* PHP-7.1:
  Fixed bug #73337 (try/catch not working with two exceptions inside a same operation)
  Revert "Fix bug #47890 #73215 uniqid() should use better random source"
  Revert "Fix bug #47890 #73215 uniqid() should use better random source"
  Update NEWS
This commit is contained in:
Dmitry Stogov 2016-10-18 15:10:03 +03:00
commit 37357d9215
4 changed files with 21 additions and 20 deletions

3
NEWS
View File

@ -9,6 +9,9 @@ PHP NEWS
(Yasuo) (Yasuo)
. Implemented FR #49806 (proc_nice() for Windows). (Kalle) . Implemented FR #49806 (proc_nice() for Windows). (Kalle)
. Fix pthreads detection when cross-compiling (ffontaine) . Fix pthreads detection when cross-compiling (ffontaine)
. Fixed bug #73215 (uniqid() should use better random source). (Yasuo)
. Fixed bug #73337 (try/catch not working with two exceptions inside a same
operation). (Dmitry)
- EXIF: - EXIF:
. Added support for vendor specific tags for the following formats: . Added support for vendor specific tags for the following formats:

12
Zend/tests/bug73337.phpt Normal file
View File

@ -0,0 +1,12 @@
--TEST--
Bug #73337 (try/catch not working with two exceptions inside a same operation)
--FILE--
<?php
class d { function __destruct() { throw new Exception; } }
try { new d + new d; } catch (Exception $e) { print "Exception properly caught\n"; }
?>
--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

View File

@ -826,10 +826,13 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
ZEND_ADD_CALL_FLAG(call, call_info); ZEND_ADD_CALL_FLAG(call, call_info);
} }
if (func->type == ZEND_USER_FUNCTION) { if (func->type == ZEND_USER_FUNCTION) {
int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0; int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
const zend_op *current_opline_before_exception = EG(opline_before_exception);
zend_init_execute_data(call, &func->op_array, fci->retval); zend_init_execute_data(call, &func->op_array, fci->retval);
zend_execute_ex(call); zend_execute_ex(call);
EG(opline_before_exception) = current_opline_before_exception;
if (call_via_handler) { if (call_via_handler) {
/* We must re-initialize function again */ /* We must re-initialize function again */
fci_cache->initialized = 0; fci_cache->initialized = 0;

View File

@ -35,11 +35,9 @@
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include "php_random.h" #include "php_lcg.h"
#include "uniqid.h" #include "uniqid.h"
#define PHP_UNIQID_ENTROPY_LEN 10
/* {{{ proto string uniqid([string prefix [, bool more_entropy]]) /* {{{ proto string uniqid([string prefix [, bool more_entropy]])
Generates a unique ID */ Generates a unique ID */
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
@ -79,22 +77,7 @@ PHP_FUNCTION(uniqid)
* digits for usecs. * digits for usecs.
*/ */
if (more_entropy) { if (more_entropy) {
int i; uniqid = strpprintf(0, "%s%08x%05x%.8F", prefix, sec, usec, php_combined_lcg() * 10);
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);
} else { } else {
uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec); uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec);
} }