[php-src] Issue #21070: PHP 8.4.17 RC 1: #71527 Buffer over-write in finfo_open with malformed magic file
[email protected] (ArchMaster2024)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <TPohnlX4fgaw4vIvwJcC3KmYce4RLv8t9BOjhRfc1q0@main.internal.php.net> |
Issue: https://github.com/php/php-src/issues/21070
Author: ArchMaster2024
### Description
The following code:
```php
$finfo = finfo_open(FILEINFO_NONE, __DIR__ . DIRECTORY_SEPARATOR . "bug71527私はガラスを食べられます.magic");
var_dump($finfo);
<?php
```
Resulted in this output:
```
Warning: finfo_open(/test_php/source/php/ext/fileinfo/tests/bug71527私はガラスを食べられます.magic): Failed to open stream: No such file or directory in /test_php/source/php/ext/fileinfo/tests/bug71527-mb.php on line 2
Warning: finfo_open(/test_php/source/php/ext/fileinfo/tests/bug71527私はガラスを食べられます.magic): Failed to open stream: No such file or directory in /test_php/source/php/ext/fileinfo/tests/bug71527-mb.php on line 2
Warning: finfo_open(): Failed to load magic database at "/test_php/source/php/ext/fileinfo/tests/bug71527私はガラスを食べられます.magic" in /test_php/source/php/ext/fileinfo/tests/bug71527-mb.php on line 2
bool(false)
```
But I expected this output instead:
```
Warning: finfo_open(): Failed to load magic database at "%sbug71527私はガラスを食べられます.magic" in %sbug71527-mb.php on line %d
bool(false)
```
### PHP Version
```plain
PHP 8.4.17RC1 (cli) (built: Jan 25 2026 21:18:17) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.17RC1, Copyright (c) Zend Technologies
```
### Operating System
Debian GNU/Linux 12 (bookworm) x86_64 (container run with podman)