mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fuzzer: Gracefully handle hashes that cannot be serialized
This commit is contained in:
@@ -6,5 +6,11 @@ $corpusDir = __DIR__ . '/corpus/unserializehash';
|
||||
foreach (hash_algos() as $algo) {
|
||||
$ctx = hash_init($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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user