[php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Weilin Du | Date: | Thu, 26 Nov 2026 10:02:49 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-144207@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-11-26T18:00:44+08:00
Commit: https://github.com/php/php-src/commit/9c3bd917a95905b7b3d1408a268afc5004ec83f8
Raw diff: https://github.com/php/php-src/commit/9c3bd917a95905b7b3d1408a268afc5004ec83f8.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix phar_set_inode() using the zend_string header instead of the filename (#25768)
Changed paths:
A ext/phar/tests/phar_set_inode_collision.phpt
M NEWS
M ext/phar/phar_internal.h
Diff:
diff --git a/NEWS b/NEWS
index 50c3719a3ccf..732dafd8c1f0 100644
--- a/NEWS
+++ b/NEWS
@@ -192,6 +192,8 @@ PHP NEWS
execute() or rebound while fetching). (Ilia Alshanetsky)
- Phar:
+ . Fixed Phar file stats using the string header instead of the entry
+ filename to compute the inode number. (Hohphu)
. Fixed bug GH-25528 (Phar::setSignatureAlgorithm(): OpenSSL signing reads a
freed private key). (Artem Ukrainskiy)
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index b78a8b0176dc..50a423f3b0fa 100644
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -413,7 +413,7 @@ static inline void phar_set_inode(phar_entry_info *entry) /* {{{ */
memcpy(tmp, ZSTR_VAL(entry->phar->fname), len1);
size_t len2 = MIN(tmp_len - len1, ZSTR_LEN(entry->filename));
- memcpy(tmp + len1, entry->filename, len2);
+ memcpy(tmp + len1, ZSTR_VAL(entry->filename), len2);
entry->inode = (unsigned short) zend_hash_func(tmp, tmp_len);
} else {
diff --git a/ext/phar/tests/phar_set_inode_collision.phpt
b/ext/phar/tests/phar_set_inode_collision.phpt
new file mode 100644
index 000000000000..b3ec0ba471f9
--- /dev/null
+++ b/ext/phar/tests/phar_set_inode_collision.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Phar: distinct same-length filenames in a phar archive should not collide on st_ino
(phar_set_inode)
+--EXTENSIONS--
+phar
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = __DIR__ . '/h13_inode_test.phar';
+@unlink($fname);
+
+$p = new Phar($fname);
+$p['aaaaa.txt'] = '1';
+$p['bbbbb.txt'] = '2';
+$p['cccccc.txt'] = '3';
+unset($p);
+
+// Verify in a clean subprocess (-n) so PHAR_G(phar_fname_map) cache is not reused
+$code = <<<'PHP'
+$f = $argv[1];
+$a = stat("phar://$f/aaaaa.txt")["ino"];
+$b = stat("phar://$f/bbbbb.txt")["ino"];
+$c = stat("phar://$f/cccccc.txt")["ino"];
+var_dump($a > 0, $a !== $b, $a !== $c, $b !== $c);
+PHP;
+
+$spec = [
+ 0 => ['pipe', 'r'],
+ 1 => ['pipe', 'w'],
+ 2 => ['pipe', 'w'],
+];
+$proc = proc_open([PHP_BINARY, '-n', '-r', $code, '--', $fname],
$spec, $pipes);
+fclose($pipes[0]);
+$stdout = stream_get_contents($pipes[1]);
+$stderr = stream_get_contents($pipes[2]);
+fclose($pipes[1]);
+fclose($pipes[2]);
+$rc = proc_close($proc);
+
+var_dump($rc === 0, $stderr === '');
+echo $stdout;
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . '/h13_inode_test.phar');
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)