OpenSSL::config: Fix trivial bugs
authorRichard Levitte <levitte@openssl.org>
Tue, 27 Sep 2022 16:51:57 +0000 (18:51 +0200)
committerHugo Landau <hlandau@openssl.org>
Thu, 29 Sep 2022 12:00:19 +0000 (13:00 +0100)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19285)

(cherry picked from commit 2ba5bffa26c0c4677f48e730628c0b54c31c734c)

util/perl/OpenSSL/config.pm

index 4c2cbd49a5a5bb23ec7a23b78408a65bfc02b1ce..2f1edcafb69f7d5de99c2fb924c8edafcb643111 100755 (executable)
@@ -15,6 +15,7 @@ use strict;
 use warnings;
 use Getopt::Std;
 use File::Basename;
+use File::Spec;
 use IPC::Cmd;
 use POSIX;
 use Config;
@@ -51,12 +52,15 @@ my @c_compilers = qw(clang gcc cc);
 my @cc_version =
     (
      clang => sub {
+         return undef unless IPC::Cmd::can_run("$CROSS_COMPILE$CC");
          my $v = `$CROSS_COMPILE$CC -v 2>&1`;
          $v =~ m/(?:(?:clang|LLVM) version|.*based on LLVM)\s+([0-9]+\.[0-9]+)/;
          return $1;
      },
      gnu => sub {
-         my $v = `$CROSS_COMPILE$CC -dumpversion 2>/dev/null`;
+         return undef unless IPC::Cmd::can_run("$CROSS_COMPILE$CC");
+         my $nul = File::Spec->devnull();
+         my $v = `$CROSS_COMPILE$CC -dumpversion 2> $nul`;
          # Strip off whatever prefix egcs prepends the number with.
          # Hopefully, this will work for any future prefixes as well.
          $v =~ s/^[a-zA-Z]*\-//;
@@ -900,7 +904,7 @@ EOF
             } else {
                 $config{disable} = [ 'asm' ];
             }
-            return %config;
+            return { %config };
         }
       ],