From 81b2533a68ffc4fdc7ba0a4b8e516fe1a495451f Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Wed, 7 Jun 2017 23:50:20 -0700 Subject: [PATCH 1/3] Fixes bug #74708 reflection signatures for random_bytes+random_int They have 1 and 2 required parameters, respectively See https://secure.php.net/manual/en/function.random-int.php --- ext/standard/basic_functions.c | 4 ++-- ext/standard/tests/random/reflection.phpt | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 ext/standard/tests/random/reflection.phpt diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 99ca20f550e62..7671cabbb5cc0 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1912,11 +1912,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_mt_getrandmax, 0) ZEND_END_ARG_INFO() /* }}} */ /* {{{ random.c */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_random_bytes, 0, 0, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_random_bytes, 0, 0, 1) ZEND_ARG_INFO(0, length) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_random_int, 0, 0, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_random_int, 0, 0, 2) ZEND_ARG_INFO(0, min) ZEND_ARG_INFO(0, max) ZEND_END_ARG_INFO() diff --git a/ext/standard/tests/random/reflection.phpt b/ext/standard/tests/random/reflection.phpt new file mode 100644 index 0000000000000..2df6a33be7318 --- /dev/null +++ b/ext/standard/tests/random/reflection.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #74708 Wrong reflection on random_bytes and random_int +--FILE-- +getNumberOfParameters()); +var_dump($rf->getNumberOfRequiredParameters()); + +$rf = new ReflectionFunction('random_int'); +var_dump($rf->getNumberOfParameters()); +var_dump($rf->getNumberOfRequiredParameters()); +?> +===DONE=== +--EXPECT-- +int(1) +int(1) +int(2) +int(2) +===DONE=== From aea8c6ddc18b9e44dd4baec2c6827bc08f40a0bd Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 13 Jun 2017 08:14:34 +0200 Subject: [PATCH 2/3] NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index a315d0369e022..daabe0175b0ee 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,10 @@ PHP NEWS . Fixed bug #74478 (null coalescing operator failing with SplFixedArray). (jhdxr) +- Standard: + . Fixed bug #74708 (Invalid Reflection signatures for random_bytes and + random_int). (Tyson Andre, Remi) + - FTP: . Fixed bug #74598 (ftp:// wrapper ignores context arg). (Sara) From 593d37376b272f990a3007957a037b57e570216e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 13 Jun 2017 08:15:19 +0200 Subject: [PATCH 3/3] NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index f0e1afccd2d33..7c37c3f64b457 100644 --- a/NEWS +++ b/NEWS @@ -288,6 +288,8 @@ PHP NEWS anonymous classes). (Adam Saponara) . Fixed bug #74105 (PHP on Linux should use /dev/urandom when getrandom is not available). (Benjamin Robin) + . Fixed bug #74708 (Invalid Reflection signatures for random_bytes and + random_int). (Tyson Andre, Remi) - Streams: . Fixed bug #73496 (Invalid memory access in zend_inline_hash_func).