Skip to content

Commit 2181129

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix order in NEWS Fix GH-21731: Random\Engine\Xoshiro256StarStar::__unserialize() accepts all-zero state (#21732)
2 parents 7415c50 + 73eace2 commit 2181129

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ext/random/engine_xoshiro256starstar.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ static bool unserialize(void *state, HashTable *data)
149149
}
150150
}
151151

152+
if (UNEXPECTED(s->state[0] == 0 && s->state[1] == 0 && s->state[2] == 0 && s->state[3] == 0)) {
153+
return false;
154+
}
155+
152156
return true;
153157
}
154158

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-21731: Xoshiro256StarStar::__unserialize() must reject the all-zero state
3+
--FILE--
4+
<?php
5+
6+
try {
7+
var_dump(unserialize('O:32:"Random\Engine\Xoshiro256StarStar":2:{i:0;a:0:{}i:1;a:4:{i:0;s:16:"0000000000000000";i:1;s:16:"0000000000000000";i:2;s:16:"0000000000000000";i:3;s:16:"0000000000000000";}}'));
8+
} catch (\Exception $e) {
9+
echo $e->getMessage(), PHP_EOL;
10+
}
11+
12+
?>
13+
--EXPECT--
14+
Invalid serialization data for Random\Engine\Xoshiro256StarStar object

0 commit comments

Comments
 (0)