Skip to content
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
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ PHP NEWS
. Fixed bug GH-24229 (fcgi_close() passes shutdown() a literal 1, which is
SHUT_RD in WASI). (Ryosuke Ishibashi)

- Fileinfo:
. Fixed bug GH-24289 (finfo::file() reports the wrong argument number for
an invalid $filename). (Lazizbek Ergashev)

- MBString:
. Fixed bug GH-23958 (truncated encoding names resolving to full names). (Kamil Tekiela)

Expand Down
4 changes: 2 additions & 2 deletions ext/fileinfo/fileinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
php_stream_wrapper *wrap;
php_stream_statbuf ssb;

// Implementation is used for both finfo_file() and mimetype_emu()
int buffer_param_num = (mimetype_emu ? 1 : 2);
// Implementation is used for finfo_file(), finfo::file() and mimetype_emu()
int buffer_param_num = (mimetype_emu || hasThis() ? 1 : 2);
if (buffer == NULL || buffer_len == 0) {
zend_argument_must_not_be_empty_error(buffer_param_num);
goto clean;
Expand Down
23 changes: 23 additions & 0 deletions ext/fileinfo/tests/gh24289.phpt
Original file line number Diff line number Diff line change
@@ -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 (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
var_dump($finfo->file("\0"));
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
}

?>
--EXPECT--
finfo::file(): Argument #1 ($filename) must not be empty
finfo::file(): Argument #1 ($filename) must not contain any null bytes
Loading