[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | ndossche | Date: | Tue, 13 Oct 2026 16:53:00 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142230@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-10-13T18:52:45+02:00
Commit: https://github.com/php/php-src/commit/9b7efbc346b69175426be33944954b4a3ea1ebf4
Raw diff: https://github.com/php/php-src/commit/9b7efbc346b69175426be33944954b4a3ea1ebf4.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix GH-24289: finfo::file() reports the wrong argument number
Changed paths:
A ext/fileinfo/tests/gh24289.phpt
M NEWS
M ext/fileinfo/fileinfo.c
Diff:
diff --git a/NEWS b/NEWS
index 746c0bb0c6d2..99d7f0f98d01 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ PHP NEWS
(Nicolas Grekas)
. Fix escape analysis for objects implementing ArrayAccess. (ndossche, Arnaud)
+- Fileinfo:
+ . Fixed bug GH-24289 (finfo::file() reports the wrong argument number for
+ an invalid $filename). (Lazizbek Ergashev)
+
- FPM:
. Fixed bug GH-24229 (fcgi_close() passes shutdown() a literal 1, which is
SHUT_RD in WASI). (Ryosuke Ishibashi)
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index 36247b7196f4..4bc76b44ea72 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -297,7 +297,7 @@ PHP_FUNCTION(finfo_file)
struct magic_set *magic = Z_FINFO_P(self)->magic;
if (UNEXPECTED(ZSTR_LEN(path) == 0)) {
- zend_argument_must_not_be_empty_error(2);
+ zend_argument_must_not_be_empty_error(hasThis() ? 1 : 2);
RETURN_THROWS();
}
php_stream_context *context = php_stream_context_from_zval(zcontext, false);
diff --git a/ext/fileinfo/tests/gh24289.phpt b/ext/fileinfo/tests/gh24289.phpt
new file mode 100644
index 000000000000..035fca7e96b4
--- /dev/null
+++ b/ext/fileinfo/tests/gh24289.phpt
@@ -0,0 +1,23 @@
+--TEST--
+GH-24289 (finfo::file() reports the wrong argument number for an invalid $filename)
+--EXTENSIONS--
+fileinfo
+--FILE--
+<?php
+
+$finfo = new finfo();
+try {
+ var_dump($finfo->file(''));
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump($finfo->file("\0"));
+} catch (Throwable $e) {
+ echo $e::class, ": ", $e->getMessage() . \PHP_EOL;
+}
+
+?>
+--EXPECT--
+ValueError: finfo::file(): Argument #1 ($filename) must not be empty
+ValueError: finfo::file(): Argument #1 ($filename) must not contain any null bytes