Skip to content

Fix GH-15268: heap buffer overflow in phpdbg (zend_hash_num_elements() Zend/zend_hash.h) #15277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions sapi/phpdbg/phpdbg_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,15 @@ PHPDBG_INFO(classes) /* {{{ */
phpdbg_print_class_name(ce);

if (ce->parent) {
zend_class_entry *pce;
pce = ce->parent;
do {
phpdbg_out("|-------- ");
phpdbg_print_class_name(pce);
} while ((pce = pce->parent));
if (ce->ce_flags & ZEND_ACC_LINKED) {
zend_class_entry *pce = ce->parent;
do {
phpdbg_out("|-------- ");
phpdbg_print_class_name(pce);
} while ((pce = pce->parent));
} else {
phpdbg_writeln("|-------- User Class %s (not yet linked because declaration for parent was not encountered when declaring the class)", ZSTR_VAL(ce->parent_name));
}
}

if (ce->info.user.filename) {
Expand Down
25 changes: 25 additions & 0 deletions sapi/phpdbg/tests/gh15268.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
GH-15268 (heap buffer overflow in phpdbg (zend_hash_num_elements() Zend/zend_hash.h))
--SKIPIF--
<?php
if (function_exists('opcache_get_status')) die('skip not for opcache because it will link');
?>
--FILE--
<?php
class B extends A {
}
class A {
}
?>
--PHPDBG--
i classes
q
--EXPECTF--
[Successful compilation of %s]
prompt> [User Classes (2)]
User Class B (0)
|-------- User Class A (not yet linked because declaration for parent was not encountered when declaring the class)
|---- in %s on line %d
User Class A (0)
|---- in %s on line %d
prompt>
Loading