[php-src] PR #25777: Fix hash() and hash_file() hanging on invalid xxh3/xxh128 options
| From: | lacatoire | Date: | Thu, 26 Nov 2026 10:46:39 +0000 |
| Subject: | [php-src] PR #25777: Fix hash() and hash_file() hanging on invalid xxh3/xxh128 options | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41041@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25777
Author: lacatoire
hash() and hash_file() went on to update the context after
hash_init() had thrown for invalid xxh3/xxh128 options (a
secret shorter than 136 bytes, or both a seed and a secret). The context is then never initialised,
and an input of 300 bytes or more never returns. Stop and release the context when
hash_init() has thrown.
### To reproduce
```php
<?php
hash('xxh3', str_repeat('z', 300), false, ['secret' =>
'short']);
```
Before (PHP 8.4.28): no output, the script never returns.
After:
```
Fatal error: Uncaught Error: xxh3: Secret length must be >= 136 bytes, 5 bytes passed
```