Skip to content

Commit 227112c

Browse files
committed
- Fixed bug #61388 (ReflectionObject:getProperties() issues invalid reads
when get_properties returns a hash table with (inaccessible) dynamic numeric properties).
1 parent 714f1ff commit 227112c

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

NEWS

+7-4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ PHP NEWS
7272
. Fixed bug #61088 (Memory leak in readline_callback_handler_install).
7373
(Nikic, Laruence)
7474

75+
- Reflection:
76+
. Fixed bug #61388 (ReflectionObject:getProperties() issues invalid reads
77+
when get_properties returns a hash table with (inaccessible) dynamic
78+
numeric properties). (Gustavo)
79+
. Fixed bug #60968 (Late static binding doesn't work with
80+
ReflectionMethod::invokeArgs()). (Laruence)
81+
7582
- SOAP
7683
. Fixed basic HTTP authentication for WSDL sub requests. (Dmitry)
7784
. Fixed bug #60887 (SoapClient ignores user_agent option and sends no
@@ -90,10 +97,6 @@ PHP NEWS
9097
- SQLite3 extension:
9198
. Add createCollation() method. (Brad Dewar)
9299

93-
- Reflection:
94-
. Fixed bug #60968 (Late static binding doesn't work with
95-
ReflectionMethod::invokeArgs()). (Laruence)
96-
97100
- Session:
98101
. Fixed bug #60860 (session.save_handler=user without defined function core
99102
dumps). (Felipe)

ext/reflection/php_reflection.c

+7
Original file line numberDiff line numberDiff line change
@@ -3667,6 +3667,13 @@ static int _adddynproperty(zval **pptr TSRMLS_DC, int num_args, va_list args, ze
36673667
zend_class_entry *ce = *va_arg(args, zend_class_entry**);
36683668
zval *retval = va_arg(args, zval*), member;
36693669

3670+
/* under some circumstances, the properties hash table may contain numeric
3671+
* properties (e.g. when casting from array). This is a WONT FIX bug, at
3672+
* least for the moment. Ignore these */
3673+
if (hash_key->nKeyLength == 0) {
3674+
return 0;
3675+
}
3676+
36703677
if (hash_key->arKey[0] == '\0') {
36713678
return 0; /* non public cannot be dynamic */
36723679
}

ext/reflection/tests/bug61388.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
ReflectionObject:getProperties() issues invalid reads when it get_properties returns a hash table with (inaccessible) dynamic numeric properties
3+
--FILE--
4+
<?php
5+
$x = new ArrayObject();
6+
$x[0] = 'test string 2';
7+
$x['test'] = 'test string 3';
8+
$reflObj = new ReflectionObject($x);
9+
print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));
10+
11+
$x = (object)array("a", "oo" => "b");
12+
$reflObj = new ReflectionObject($x);
13+
print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));
14+
--EXPECT--
15+
Array
16+
(
17+
[0] => ReflectionProperty Object
18+
(
19+
[name] => test
20+
[class] => ArrayObject
21+
)
22+
23+
)
24+
Array
25+
(
26+
[0] => ReflectionProperty Object
27+
(
28+
[name] => oo
29+
[class] => stdClass
30+
)
31+
32+
)

0 commit comments

Comments
 (0)