]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ecp_sm2p256-armv8.pl: Copy the argument handling from ecp_nistz256-armv8.pl
authorTomas Mraz <tomas@openssl.org>
Mon, 28 Aug 2023 16:49:02 +0000 (18:49 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 31 Aug 2023 07:40:51 +0000 (09:40 +0200)
Popping the $output argument is more robust and it also needs to be
placed in double quotes to handle spaces in paths.

Fixes #21874
Fixes #21876

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/21877)

crypto/ec/asm/ecp_sm2p256-armv8.pl

index da4c16c309cd3ed5e41dde3492cfda35186d6343..50950865e43402bd9db9ad9cfb286d88c248c660 100644 (file)
@@ -6,15 +6,18 @@
 # in the file LICENSE in the source distribution or at
 # https://www.openssl.org/source/license.html
 
-$flavour = shift;
-while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
+# $output is the last argument if it looks like a file (it has an extension)
+# $flavour is the first argument if it doesn't look like a file
+$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
+$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
 
 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
 ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
 ( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
 die "can't locate arm-xlate.pl";
 
-open OUT,"| \"$^X\" $xlate $flavour $output";
+open OUT,"| \"$^X\" $xlate $flavour \"$output\""
+    or die "can't call $xlate: $!";
 *STDOUT=*OUT;
 
 my ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7)=map("x$_",(7..14));