[php-src] PR #25768: Fix phar_set_inode() using zend_string header instead of filename
| From: | hohphu8 | Date: | Thu, 26 Nov 2026 03:53:53 +0000 |
| Subject: | [php-src] PR #25768: Fix phar_set_inode() using zend_string header instead of filename | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41028@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25768
Author: hohphu8
phar_set_inode() in ext/phar/phar_internal.h passes
entry->filename to memcpy(). Since
phar_entry_info.filename is a zend_string * in PHP 8.5, this copies from
the start of the zend_string struct (header) rather than from the filename characters:
```c
memcpy(tmp + len1, entry->filename, len2);
```
As a result the inode is not derived from the actual filename, and entries with same-length names
can end up with the same st_ino. The fix is to copy from
ZSTR_VAL(entry->filename).
Adds a regression test (ext/phar/tests/phar_set_inode_collision.phpt) that checks
distinct entries get distinct inodes. It fails before the fix and passes after. I ran it on PHP-8.5
NTS debug and ZTS builds, and the full ext/phar/tests/ passes.
Targeting PHP-8.5 because filename is still a char * in PHP-8.4 (not
affected).
Note: I found this through source inspection with an automated/LLM-assisted tool, then reproduced
and verified it myself.