isaacpittman-hitachi / rpms / openssl

Forked from rpms/openssl 2 years ago
Clone
22d461
diff --git a/tools/c_rehash.in b/tools/c_rehash.in
22d461
index d51d8856d7..a630773a02 100644
22d461
--- a/tools/c_rehash.in
22d461
+++ b/tools/c_rehash.in
22d461
@@ -152,6 +152,23 @@ sub check_file {
22d461
     return ($is_cert, $is_crl);
22d461
 }
22d461
 
22d461
+sub compute_hash {
22d461
+    my $fh;
22d461
+    if ( $^O eq "VMS" ) {
22d461
+        # VMS uses the open through shell
22d461
+        # The file names are safe there and list form is unsupported
22d461
+        if (!open($fh, "-|", join(' ', @_))) {
22d461
+            print STDERR "Cannot compute hash on '$fname'\n";
22d461
+            return;
22d461
+        }
22d461
+    } else {
22d461
+        if (!open($fh, "-|", @_)) {
22d461
+            print STDERR "Cannot compute hash on '$fname'\n";
22d461
+            return;
22d461
+        }
22d461
+    }
22d461
+    return (<$fh>, <$fh>);
22d461
+}
22d461
 
22d461
 # Link a certificate to its subject name hash value, each hash is of
22d461
 # the form <hash>.<n> where n is an integer. If the hash value already exists
22d461
@@ -161,10 +178,12 @@ sub check_file {
22d461
 
22d461
 sub link_hash_cert {
22d461
     my $fname = $_[0];
22d461
-    $fname =~ s/\"/\\\"/g;
22d461
-    my ($hash, $fprint) = `"$openssl" x509 $x509hash -fingerprint -noout -in "$fname"`;
22d461
+    my ($hash, $fprint) = compute_hash($openssl, "x509", $x509hash,
22d461
+                                       "-fingerprint", "-noout",
22d461
+                                       "-in", $fname);
22d461
     chomp $hash;
22d461
     chomp $fprint;
22d461
+    return if !$hash;
22d461
     $fprint =~ s/^.*=//;
22d461
     $fprint =~ tr/://d;
22d461
     my $suffix = 0;
22d461
@@ -202,10 +221,12 @@ sub link_hash_cert {
22d461
 
22d461
 sub link_hash_crl {
22d461
     my $fname = $_[0];
22d461
-    $fname =~ s/'/'\\''/g;
22d461
-    my ($hash, $fprint) = `"$openssl" crl $crlhash -fingerprint -noout -in '$fname'`;
22d461
+    my ($hash, $fprint) = compute_hash($openssl, "crl", $crlhash,
22d461
+                                       "-fingerprint", "-noout",
22d461
+                                       "-in", $fname);
22d461
     chomp $hash;
22d461
     chomp $fprint;
22d461
+    return if !$hash;
22d461
     $fprint =~ s/^.*=//;
22d461
     $fprint =~ tr/://d;
22d461
     my $suffix = 0;