From 39a6d9bcd6fde6e1dd492c1b2e7c0f55eb1ce7bd Mon Sep 17 00:00:00 2001 From: Scott Kitterman Date: Wed, 25 Jan 2012 22:54:02 -0500 Subject: [PATCH] * Chomp erroneus NULLs off the end of local and authority explanations to work around a Mail::SPF bug (in Mail::SPF versions prior to 2.008) - Patch thanks to Allison Randal --- CHANGES | 3 +++ postfix-policyd-spf-perl | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index d5269bb..f68d5c4 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,9 @@ # * = Fixed a bug, or made a minor improvement --- 2.009 UNRELEASED + * Chomp erroneus NULLs off the end of local and authority explanations to + work around a Mail::SPF bug (in Mail::SPF versions prior to 2.008) + - Patch thanks to Allison Randal --- 2.008 (2012-01-19 13:46 -0500) ! Query only TXT and not DNS RR Type SPF records to reduce unnecessary DNS lookups (LP: #161133) diff --git a/postfix-policyd-spf-perl b/postfix-policyd-spf-perl index 6b43403..4293394 100755 --- a/postfix-policyd-spf-perl +++ b/postfix-policyd-spf-perl @@ -250,8 +250,8 @@ sub sender_policy_framework { } my $helo_result_code = $helo_result->code; # 'pass', 'fail', etc. - my $helo_local_exp = $helo_result->local_explanation; - my $helo_authority_exp = $helo_result->authority_explanation + my $helo_local_exp = nullchomp($helo_result->local_explanation); + my $helo_authority_exp = nullchomp($helo_result->authority_explanation) if $helo_result->is_code('fail'); my $helo_spf_header = $helo_result->received_spf_header; @@ -327,8 +327,8 @@ sub sender_policy_framework { } my $mfrom_result_code = $mfrom_result->code; # 'pass', 'fail', etc. - my $mfrom_local_exp = $mfrom_result->local_explanation; - my $mfrom_authority_exp = $mfrom_result->authority_explanation + my $mfrom_local_exp = nullchomp($mfrom_result->local_explanation); + my $mfrom_authority_exp = nullchomp($mfrom_result->authority_explanation) if $mfrom_result->is_code('fail'); my $mfrom_spf_header = $mfrom_result->received_spf_header; @@ -360,3 +360,16 @@ sub sender_policy_framework { return; } + +# ---------------------------------------------------------- +# utility, string cleaning +# ---------------------------------------------------------- + +sub nullchomp { + my $value = shift; + + # Remove one or more null characters from the + # end of the input. + $value =~ s/\0+$//; + return $value; +}