Skip to content
Open
Changes from 1 commit
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
Next Next commit
Fix GH-21986: PharData::getContent() crash on infinite recursion with…
… symlinks.

The entries being unbounded when cycling through them, it blows the
stack.
  • Loading branch information
devnexen committed May 8, 2026
commit 1300018550a6264614f81cbc7646fdae1bfc3762
30 changes: 20 additions & 10 deletions ext/phar/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,34 @@ phar_entry_info *phar_get_link_source(phar_entry_info *entry) /* {{{ */
{
phar_entry_info *link_entry;
char *link;
uint32_t depth = 0, max_depth;

if (!entry->link) {
return entry;
}

link = phar_get_link_location(entry);
if (NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), entry->link, strlen(entry->link))) ||
NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), link, strlen(link)))) {
if (link != entry->link) {
efree(link);
max_depth = zend_hash_num_elements(&(entry->phar->manifest));

while (entry->link) {
if (UNEXPECTED(++depth > max_depth)) {
return NULL;
}
return phar_get_link_source(link_entry);
} else {
if (link != entry->link) {
efree(link);
link = phar_get_link_location(entry);

if (NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), entry->link, strlen(entry->link))) ||
NULL != (link_entry = zend_hash_str_find_ptr(&(entry->phar->manifest), link, strlen(link)))) {
if (link != entry->link) {
efree(link);
}
entry = link_entry;
} else {
if (link != entry->link) {
efree(link);
}
return NULL;
}
return NULL;
}
return entry;
}
/* }}} */

Expand Down
Loading