[PATCH] concatenate blocks before encoding them to base64
[email protected] Mon, 21 Mar 2016 08:19:56 +0100
| Newsgroups | gmane.comp.log.logwatch.devel |
|---|---|
| Message-ID | <[email protected]> |
From: Jan Synacek <[email protected]> Encoding blocks first and then concatenating them might result in an invalid message in some cases. Original report: https://bugzilla.redhat.com/show_bug.cgi?id=1123093 --- scripts/logwatch.pl | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/scripts/logwatch.pl b/scripts/logwatch.pl index 44e43b5..939d897 100755 --- a/scripts/logwatch.pl +++ b/scripts/logwatch.pl @@ -1458,24 +1458,21 @@ sub parselogs { #Printing starts here $out_mime $out_head $out_reference $out_body $out_foot if (defined fileno OUTFILE) { + my $out = ''; print OUTFILE $out_mime if $out_mime; - if ( $Config{'encode'} eq "base64" ) { - print OUTFILE encode_base64($out_head) if $out_head; - print OUTFILE encode_base64($out_reference) if $out_reference; - foreach ( 0 .. $index_par ) { - print OUTFILE encode_base64($out_body{$_}) if defined( $out_body{$_} ); + + $out .= $out_head if $out_head; + $out .= $out_reference if $out_reference; + foreach ( 0 .. $index_par ) { + $out .= $out_body{$_} if defined( $out_body{$_} ); #fixme - $out_body{$_} = ''; #We should track this down out_body could be an array instead also -mgt - } - print OUTFILE encode_base64($out_foot) if $out_foot; + $out_body{$_} = ''; #We should track this down out_body could be an array instead also -mgt + } + $out .= $out_foot if $out_foot; + if ( $Config{'encode'} eq "base64" ) { + print OUTFILE encode_base64($out); } else { - print OUTFILE $out_head if $out_head; - print OUTFILE $out_reference if $out_reference; - foreach ( 0 .. $index_par ) { - print OUTFILE $out_body{$_} if defined( $out_body{$_} ); - $out_body{$_} = ''; - } - print OUTFILE $out_foot if $out_foot; + print OUTFILE $out; } } #ends here -- 2.7.3 ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140