mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fuzzer: Gracefully handle hashes that cannot be serialized
This commit is contained in:
parent
c7fe18aca6
commit
3b542021e4
1 changed files with 7 additions and 1 deletions
|
@ -6,5 +6,11 @@ $corpusDir = __DIR__ . '/corpus/unserializehash';
|
||||||
foreach (hash_algos() as $algo) {
|
foreach (hash_algos() as $algo) {
|
||||||
$ctx = hash_init($algo);
|
$ctx = hash_init($algo);
|
||||||
$algx = preg_replace('/[^-_a-zA-Z0-9]/', '_', $algo);
|
$algx = preg_replace('/[^-_a-zA-Z0-9]/', '_', $algo);
|
||||||
file_put_contents($corpusDir . '/' . $algx, "x|" . serialize($ctx));
|
try {
|
||||||
|
$serialized = serialize($ctx);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Hash algorithm $algo could not be serialized.\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
file_put_contents($corpusDir . '/' . $algx, "x|" . $serialized);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue