]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mk-ca-bundle.pl: use `open()` with argument list to replace backticks
authorViktor Szakats <commit@vsz.me>
Tue, 11 Nov 2025 10:09:36 +0000 (11:09 +0100)
committerViktor Szakats <commit@vsz.me>
Tue, 11 Nov 2025 23:53:43 +0000 (00:53 +0100)
On Windows this requires Perl 5.22 from year 2015.

Also:
- mdlinkcheck: delete redundant error handling logic.
  Follow-up to 77be4a7ab2b5a0c633b9107fd286bda1f57e4725 #19437

Closes #19461

scripts/mdlinkcheck
scripts/mk-ca-bundle.pl

index 842f0c97665897c96718427fb21108ed73a742b9..6b648786f33e6f4210090eb3e5ea4b5131800952 100755 (executable)
@@ -145,10 +145,6 @@ sub checkurl {
         @content = <$fh>;
         close $fh;
     }
-    else {
-        print STDERR "FAIL\n";
-        return 1; # fail
-    }
     if(!$content[0]) {
         print STDERR "FAIL\n";
         return 1; # fail
index cb0b5860932678c3ce2759227a854dce97b62b28..af31ccd10e8fb8909502286cc93a6345ba351e0e 100755 (executable)
@@ -247,7 +247,9 @@ sub sha256 {
         close(FILE);
     } else {
         # Use OpenSSL command if Perl Digest::SHA modules not available
-        $result = `"$openssl" dgst -r -sha256 "$_[0]"`;
+        open(my $fh, '-|', $openssl, 'dgst', '-r', '-sha256', $_[0]) or die "Failed running openssl on '$_[0]': $!";
+        $result = <$fh>;  # read first line
+        close $fh;
         $result =~ s/^([0-9a-f]{64}) .+/$1/is;
     }
     return $result;
@@ -311,10 +313,16 @@ if(!$opt_n) {
         if($curl) {
             if($curl =~ /^Protocols:.* https( |$)/m) {
                 report "Get certdata with curl!";
-                my $proto = !$opt_k ? "--proto =https" : "";
-                my $quiet = $opt_q ? "-s" : "";
-                my @out = `curl -Lw %{response_code} $proto $quiet -o "$txt" "$url"`;
-                if(!$? && @out && $out[0] == 200) {
+                my @opts = ();
+                push @opts, '--proto', '=https' if !$opt_k;
+                push @opts, '-s' if $opt_q;
+                my $out = '';
+                if(open(my $fh, '-|', 'curl', '-Lw', '%{response_code}', (@opts), '-o', $txt, $url)) {
+                    $out = <$fh>;  # read first line
+                    chomp $out;
+                    close $fh;
+                }
+                if($out && $out == 200) {
                     $fetched = 1;
                     report "Downloaded $txt";
                 }