[php-src] PR #21732: Fix GH-21731: Random\Engine\Xoshiro256StarStar::__unserialize() accepts all-zero state
| From: | iliaal | Date: | Sun, 12 Apr 2026 02:24:38 +0000 |
| Subject: | [php-src] PR #21732: Fix GH-21731: Random\Engine\Xoshiro256StarStar::__unserialize() accepts all-zero state | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35683@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21732
Author: iliaal
Fixes #21731.
Random\Engine\Xoshiro256StarStar::__construct() rejects a seed that would leave the
internal state all zero, because xoshiro256** with zero state returns 0 on every call
forever. The unserialize callback didn't check the same invariant. A caller
feeding a crafted serialized payload through __unserialize() ended up with a live
engine that returned 0 from every operation.
Match the constructor: reject the all-zero state from unserialize too. The
Mt19937-aliased __unserialize() wrapper maps the false return into the
standard "Invalid serialization data for ... object" exception, so the wrapper needs no
changes.