Skip to content

Commit a5c8342

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-15268: heap buffer overflow in phpdbg (zend_hash_num_elements() Zend/zend_hash.h)
2 parents c8b45aa + 47e4991 commit a5c8342

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

sapi/phpdbg/phpdbg_info.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,15 @@ PHPDBG_INFO(classes) /* {{{ */
403403
phpdbg_print_class_name(ce);
404404

405405
if (ce->parent) {
406-
zend_class_entry *pce;
407-
pce = ce->parent;
408-
do {
409-
phpdbg_out("|-------- ");
410-
phpdbg_print_class_name(pce);
411-
} while ((pce = pce->parent));
406+
if (ce->ce_flags & ZEND_ACC_LINKED) {
407+
zend_class_entry *pce = ce->parent;
408+
do {
409+
phpdbg_out("|-------- ");
410+
phpdbg_print_class_name(pce);
411+
} while ((pce = pce->parent));
412+
} else {
413+
phpdbg_writeln("|-------- User Class %s (not yet linked because declaration for parent was not encountered when declaring the class)", ZSTR_VAL(ce->parent_name));
414+
}
412415
}
413416

414417
if (ce->info.user.filename) {

sapi/phpdbg/tests/gh15268.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
GH-15268 (heap buffer overflow in phpdbg (zend_hash_num_elements() Zend/zend_hash.h))
3+
--SKIPIF--
4+
<?php
5+
if (function_exists('opcache_get_status')) die('skip not for opcache because it will link');
6+
?>
7+
--FILE--
8+
<?php
9+
class B extends A {
10+
}
11+
class A {
12+
}
13+
?>
14+
--PHPDBG--
15+
i classes
16+
q
17+
--EXPECTF--
18+
[Successful compilation of %s]
19+
prompt> [User Classes (2)]
20+
User Class B (0)
21+
|-------- User Class A (not yet linked because declaration for parent was not encountered when declaring the class)
22+
|---- in %s on line %d
23+
User Class A (0)
24+
|---- in %s on line %d
25+
prompt>

0 commit comments

Comments
 (0)