summaryrefslogtreecommitdiff
path: root/sapi/fuzzer/generate_unserializehash_corpus.php
blob: c7c592542806f6cb34181712a64b796d70262f3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php

$corpusDir = __DIR__ . '/corpus/unserializehash';
@mkdir($corpusDir);

foreach (hash_algos() as $algo) {
    $ctx = hash_init($algo);
    $algx = preg_replace('/[^-_a-zA-Z0-9]/', '_', $algo);
    try {
        $serialized = serialize($ctx);
    } catch (Exception $e) {
        echo "Hash algorithm $algo could not be serialized.\n";
        continue;
    }
    file_put_contents($corpusDir . '/' . $algx, "x|" . $serialized);
}