Skip to content

Commit 3b54202

Browse files
committed
Fuzzer: Gracefully handle hashes that cannot be serialized
1 parent c7fe18a commit 3b54202

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sapi/fuzzer/generate_unserializehash_corpus.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66
foreach (hash_algos() as $algo) {
77
$ctx = hash_init($algo);
88
$algx = preg_replace('/[^-_a-zA-Z0-9]/', '_', $algo);
9-
file_put_contents($corpusDir . '/' . $algx, "x|" . serialize($ctx));
9+
try {
10+
$serialized = serialize($ctx);
11+
} catch (Exception $e) {
12+
echo "Hash algorithm $algo could not be serialized.\n";
13+
continue;
14+
}
15+
file_put_contents($corpusDir . '/' . $algx, "x|" . $serialized);
1016
}

0 commit comments

Comments
 (0)