/* Provenance: openssl/openssl hash_dir (vuln). * repo: openssl/openssl * commit: abebcec7b1a30fbb1fd5c5cbbe8817690c139163 * parent: abebcec7b1a30fbb1fd5c5cbbe8817690c139163 * commit_url: https://github.com/openssl/openssl/commit/2c9c35870601b4a44d86ddbf512b38df38285cfa * cve: CVE-2022-2068 * license: Apache-2.0 * function: hash_dir * relpath: tools/c_rehash.in */ sub hash_dir { my %hashlist; print "Doing $_[0]\n"; chdir $_[0]; opendir(DIR, "."); my @flist = sort readdir(DIR); closedir DIR; if ( $removelinks ) { # Delete any existing symbolic links foreach (grep {/^[\da-f]+\.r{0,1}\d+$/} @flist) { if (-l $_) { print "unlink $_" if $verbose; unlink $_ || warn "Can't unlink $_, $!\n"; } } } FILE: foreach $fname (grep {/\.(pem)|(crt)|(cer)|(crl)$/} @flist) { # Check to see if certificates and/or CRLs present. my ($cert, $crl) = check_file($fname); if (!$cert && !$crl) { print STDERR "WARNING: $fname does not contain a certificate or CRL: skipping\n"; next; } link_hash_cert($fname) if ($cert); link_hash_crl($fname) if ($crl); } }