1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fixed GH-18267 finfo_file() crashing on invalid URL protocol. (#18269)

Close GH-18267
This commit is contained in:
David CARLIER
2025-04-08 22:43:11 +01:00
committed by GitHub
parent aa0c54dade
commit 2d39c7855a
2 changed files with 17 additions and 0 deletions

View File

@@ -344,6 +344,9 @@ PHP_FUNCTION(finfo_file)
RETURN_THROWS();
}
php_stream_context *context = php_stream_context_from_zval(zcontext, false);
if (!context) {
RETURN_THROWS();
}
/* Set options for the current file/buffer. */
if (options) {

View File

@@ -0,0 +1,14 @@
--TEST--
GH-18267 finfo_file() assertion trigger on NULL stream context
--EXTENSIONS--
fileinfo
--FILE--
<?php
$cls = new finfo();
try {
$cls->file("test",FILEINFO_NONE, STDERR);
} catch (\TypeError $e) {
echo $e->getMessage();
}
--EXPECT--
finfo::file(): supplied resource is not a valid Stream-Context resource