Bug #77339 [Com]: __callStatic may get incorrect arguments
Edit report at https://bugs.php.net/bug.php?id=77339&edit=1
ID: 77339
Comment by: aleahaerul at gmail dot com
Reported by: php at zsxsoft dot com
Summary: __callStatic may get incorrect arguments
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: macOS 10.14.2
PHP Version: 7.3.0
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
Thanks for such a great post and the review, I am totally impressed! also visit the mimaye.com
website if you want to find out a lot of information
Previous Comments:
------------------------------------------------------------------------
[2018-12-24 10:25:33] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7e597f48e9fda982e930e4f617d2b2d98d8878a5
Log: Fixed bug #77339 (__callStatic may get incorrect arguments)
------------------------------------------------------------------------
[2018-12-23 14:21:49] cmb@php.net
For reference: <https://3v4l.org/4ZQNJ>.
------------------------------------------------------------------------
[2018-12-23 14:20:52] cmb@php.net
This regression is caused by commit d1d1aff[1]. Dmitry, could you
please have a look at this issue?
[1] <http://git.php.net/?p=php-src.git;a=commit;h=d1d1aff4e54a014d3d3693fe4505517226402eea>
------------------------------------------------------------------------
[2018-12-23 02:02:53] php at zsxsoft dot com
Description:
------------
This only happened in PHP 7.3.
Test script followed. $arguments should be ['getSomeWhat'], but __callStatic get [?] here.
I checked *myht->arData, $arguments[0] got a wrong type.
The normal one, you can see type = 0x6:
(_zval_struct::(anonymous union)) u1 = {
(_zval_struct::(anonymous struct)) v = {
(zend_uchar) type = '\x06'
(zend_uchar) type_flags = '\x01'
(_zval_struct::(anonymous union)) u = {
(uint16_t) call_info = 0
(uint16_t) extra = 0
}
}
(uint32_t) type_info = 262
}
(lldb) fr v --show-types *myht->arData->val.value.str
(zend_string) *myht->arData->val.value.str = {
(zend_refcounted_h) gc = {
(uint32_t) refcount = 1
(_zend_refcounted_h::(anonymous union)) u = {
(uint32_t) type_info = 6
}
}
(zend_ulong) h = 0
(size_t) len = 6
(char [1]) val = "aaazzz"
}
The __callStatic's argument, you can see data is normal but type is not initialized.
(_zval_struct::(anonymous union)) u1 = {
(_zval_struct::(anonymous struct)) v = {
(zend_uchar) type = '\0'
(zend_uchar) type_flags = '\0'
(_zval_struct::(anonymous union)) u = {
(uint16_t) call_info = 0
(uint16_t) extra = 0
}
}
(uint32_t) type_info = 0
}
(_zval_struct::(anonymous union)) u2 = {
(uint32_t) next = 4294967295
(uint32_t) cache_slot = 4294967295
(uint32_t) opline_num = 4294967295
(uint32_t) lineno = 4294967295
(uint32_t) num_args = 4294967295
(uint32_t) fe_pos = 4294967295
(uint32_t) fe_iter_idx = 4294967295
(uint32_t) access_flags = 4294967295
(uint32_t) property_guard = 4294967295
(uint32_t) constant_flags = 4294967295
(uint32_t) extra = 4294967295
}
Test script:
---------------
<?php
class Foo
{
static function __callStatic($name, $arguments) {
if ($name === 'get') {
if (!isset($arguments[0])) {
var_dump(['getSomeWhat']);
var_dump($arguments);
exit;
}
}
echo 'OK';
}
protected function get ($key) {
// BUG!!!
}
}
class Bar
{
static function __callStatic($name, $arguments) {
echo Foo::get('getSomeWhat');
}
}
Bar::someUndefinedStaticFunction();
Expected result:
----------------
OK
Actual result:
--------------
array(1) {
[0]=>
string(11) "getSomeWhat"
}
array(1) {
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77339&edit=1
Thread (5 messages)