Do not silently truncate files on perlasm errors

If one of the perlasm xlate drivers crashes, OpenSSL's build will
currently swallow the error and silently truncate the output to however
far the driver got. This will hopefully fail to build, but better to
check such things.

Handle this by checking for errors when closing STDOUT (which is a pipe
to the xlate driver).

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10883)
This commit is contained in:
David Benjamin 2020-01-17 16:53:56 -05:00 committed by Tomas Mraz
parent 3b740f6ec0
commit 32be631ca1
162 changed files with 162 additions and 162 deletions

View File

@ -2995,4 +2995,4 @@ sub deckey()
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1245,4 +1245,4 @@ while(<SELF>) {
close SELF;
print $code;
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -1378,4 +1378,4 @@ AES_Td4:
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2203,4 +2203,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1038,4 +1038,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1460,4 +1460,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2281,4 +2281,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT; # force flush
close STDOUT or die "error closing STDOUT"; # force flush

View File

@ -1188,4 +1188,4 @@ ___
$code =~ s/fmovs.*$//gm;
print $code;
close STDOUT; # ensure flush
close STDOUT or die "error closing STDOUT"; # ensure flush

View File

@ -2919,4 +2919,4 @@ $code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1266,4 +1266,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1473,4 +1473,4 @@ $code =~ s/\`([^\`]*)\`/eval($1)/gem;
$code =~ s/\b(aes.*%xmm[0-9]+).*$/aesni($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2145,4 +2145,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1801,4 +1801,4 @@ sub rex {
$code =~ s/\`([^\`]*)\`/eval $1/gem;
$code =~ s/\b(sha256[^\s]*)\s+(.*)/sha256op38($1,$2)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -3410,4 +3410,4 @@ my ($l_,$block,$i1,$i3,$i5) = ($rounds_,$key_,$rounds,$len,$out);
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -5156,4 +5156,4 @@ $code =~ s/\bmovbe\s+%eax,\s*([0-9]+)\(%rsp\)/movbe($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -3808,4 +3808,4 @@ foreach(split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -925,4 +925,4 @@ ___
&emit_assembler();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2237,4 +2237,4 @@ if ($flavour =~ /64/) { ######## 64-bit code
}
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2491,4 +2491,4 @@ close SELF;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -3238,4 +3238,4 @@ $code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1278,4 +1278,4 @@ ___
} }
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1595,4 +1595,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -911,4 +911,4 @@ $k_dsbo=0x2c0; # decryption sbox final output
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1240,4 +1240,4 @@ $code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -253,4 +253,4 @@ OPENSSL_instrument_bus2:
___
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -147,4 +147,4 @@ CRYPTO_memcmp:
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -297,4 +297,4 @@ atomic_add_spinlock:
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -31,7 +31,7 @@ $tmp4="edx";
&cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1);
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
sub BF_encrypt
{

View File

@ -324,4 +324,4 @@ bn_mul_mont:
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -338,4 +338,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -763,4 +763,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1514,4 +1514,4 @@ ___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -30,7 +30,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
sub bn_mul_add_words
{

View File

@ -156,4 +156,4 @@ $code.=<<___;
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -21,7 +21,7 @@ $output = pop and open STDOUT,">$output";
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
sub mul_add_c
{

View File

@ -858,4 +858,4 @@ ___
open STDOUT,">$output" if $output;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -433,4 +433,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2262,4 +2262,4 @@ $code.=<<___;
.end bn_sqr_comba4
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1005,4 +1005,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1991,4 +1991,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2013,4 +2013,4 @@ Lppcasm_maw_adios:
EOF
$data =~ s/\`([^\`]*)\`/eval $1/gem;
print $data;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1653,4 +1653,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1981,4 +1981,4 @@ rsaz_1024_gather5_avx2:
___
}}}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2430,4 +2430,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -227,4 +227,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -283,4 +283,4 @@ foreach (split("\n",$code)) {
s/_dswap\s+(%r[0-9]+)/sprintf("rllg\t%s,%s,32",$1,$1) if($SIZE_T==4)/e;
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1224,4 +1224,4 @@ ___
&emit_assembler();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -196,4 +196,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -616,4 +616,4 @@ $code.=<<___;
___
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -886,4 +886,4 @@ $code =~ s/fzeros\s+%f([0-9]+)/
print $code;
# flush
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -247,4 +247,4 @@ $sp=&DWP(28,"esp");
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -380,4 +380,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -321,4 +321,4 @@ if ($sse2) {
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -627,4 +627,4 @@ $sbit=$num;
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -423,4 +423,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1591,4 +1591,4 @@ ___
}
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -3962,4 +3962,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -284,4 +284,4 @@ bus_loop2_done?:
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1146,4 +1146,4 @@ my ($s0,$s1,$s2,$s3) = @T;
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1152,4 +1152,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -935,4 +935,4 @@ ___
&emit_assembler();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -45,7 +45,7 @@ $S4="CAST_S_table3";
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
sub CAST_encrypt {
local($name,$enc)=@_;

View File

@ -1166,4 +1166,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1289,4 +1289,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT; # flush
close STDOUT or die "error closing STDOUT"; # flush

View File

@ -922,4 +922,4 @@ $code.=<<___;
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -288,4 +288,4 @@ stringz "ChaCha20 for IA64, CRYPTOGAMS by \@dot-asm"
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1349,4 +1349,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1151,4 +1151,4 @@ sub XOPROUND {
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -4004,4 +4004,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -24,7 +24,7 @@ $R="esi";
&fcrypt_body("fcrypt_body");
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
sub fcrypt_body
{

View File

@ -46,7 +46,7 @@ $small_footprint=1 if (grep(/\-DOPENSSL_SMALL_FOOTPRINT/,@ARGV));
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
sub DES_encrypt_internal()
{

View File

@ -623,4 +623,4 @@ ___
&emit_assembler();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1853,4 +1853,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -1874,4 +1874,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -2079,4 +2079,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -2382,4 +2382,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -3056,4 +3056,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1858,4 +1858,4 @@ for ($i=0;$i<7;$i++) {
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -4738,4 +4738,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -824,4 +824,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1130,4 +1130,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -45,7 +45,7 @@ $X="esi";
&md5_block("md5_block_asm_data_order");
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
sub Np
{

View File

@ -436,4 +436,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -392,4 +392,4 @@ ___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -5719,4 +5719,4 @@ if ($flavour =~ /64/) { ######## 64-bit code
}
}
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -1106,4 +1106,4 @@ $code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -463,5 +463,5 @@ rem_4bit:
___
$output=pop and open STDOUT,">$output";
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -551,4 +551,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -243,4 +243,4 @@ $code.=<<___;
___
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -467,4 +467,4 @@ $code =~ s/mux1(\s+)\S+\@rev/nop.i$1 0x0/gm if ($big_endian);
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -748,4 +748,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -261,4 +261,4 @@ ___
$code =~ s/\`([^\`]*)\`/eval $1/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -577,4 +577,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -1377,7 +1377,7 @@ my ($Xhi,$Xi)=@_;
&asciz("GHASH for x86, CRYPTOGAMS by <appro\@openssl.org>");
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
# A question was risen about choice of vanilla MMX. Or rather why wasn't
# SSE2 chosen instead? In addition to the fact that MMX runs on legacy

View File

@ -1817,4 +1817,4 @@ $code =~ s/\`([^\`]*)\`/eval($1)/gem;
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -671,4 +671,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -794,4 +794,4 @@ if ($flavour =~ /64/) { ######## 64-bit code
}
}
close STDOUT; # enforce flush
close STDOUT or die "error closing STDOUT"; # enforce flush

View File

@ -275,5 +275,5 @@ foreach(split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -191,4 +191,4 @@ while(my $line=<>) {
print "\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

View File

@ -343,4 +343,4 @@ while($line=<>) {
print "\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";

Some files were not shown because too many files have changed in this diff Show More