Fuzzer: Gracefully handle hashes that cannot be serialized

This commit is contained in:
Nikita Popov 2021-01-11 15:44:42 +01:00
parent c7fe18aca6
commit 3b542021e4

View file

@ -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);
}