[php-src] PR #23534: ext/hash: report argument #2 ($filename) for null bytes in hash_file()
| From: | lacatoire | Date: | Tue, 01 Sep 2026 18:57:18 +0000 |
| Subject: | [php-src] PR #23534: ext/hash: report argument #2 ($filename) for null bytes in hash_file() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-38255@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23534
Author: lacatoire
php_hash_do_hash() hardcodes argument index 1 in its isfilename branch, so
hash_file() blames $algo for a null byte that was carried by
$filename. hash_file() is the only caller passing isfilename =
1, and its filename is argument #2.
Before:
```
ValueError: hash_file(): Argument #1 ($algo) must not contain any null bytes
```
After:
```
ValueError: hash_file(): Argument #2 ($filename) must not contain any null bytes
```
php_hash_do_hash_hmac() already reports 2 for the same check, so
hash_hmac_file() was right and hash_file() was the odd one out. Only the
error message changes; a test case is added.