[PATCH] tinews.pl: Cancel-Lock with sha512 gets truncated
Dennis Preiser <[email protected]> Thu, 21 Sep 2017 21:36:45 +0200
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
--tKW2IUtsqtDRztdT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello,
due to the fact that encode_base64() breaks the string into lines with
no more than 76 characters, Cancel-Lock:-headers with sha512 were
truncated. See <http://perldoc.perl.org/MIME/Base64.html>.
The attached patch fixes this.
Dennis
--tKW2IUtsqtDRztdT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="2017-09-21.diff"
diff -urp tin-2.4.2_r3/tools/tinews.pl tin-2.4.2_r4/tools/tinews.pl
--- tin-2.4.2_r3/tools/tinews.pl 2017-07-02 08:36:12.000000000 +0200
+++ tin-2.4.2_r4/tools/tinews.pl 2017-09-21 21:21:35.000000000 +0200
@@ -400,9 +400,9 @@ if ($config{'canlock_secret'} && !$confi
my $cancel_lock = buildcancellock($cancel_key, $sha_mod);
if (defined($Header{'cancel-lock'})) {
chomp $Header{'cancel-lock'};
- $Header{'cancel-lock'} .= " " . $config{'canlock_algorithm'} . ":" . $cancel_lock;
+ $Header{'cancel-lock'} .= " " . $config{'canlock_algorithm'} . ":" . $cancel_lock . "\n";
} else {
- $Header{'cancel-lock'} = "Cancel-Lock: " . $config{'canlock_algorithm'} . ":" . $cancel_lock;
+ $Header{'cancel-lock'} = "Cancel-Lock: " . $config{'canlock_algorithm'} . ":" . $cancel_lock . "\n";
}
if ((defined($Header{'supersedes'}) && $Header{'supersedes'} =~ m/^Supersedes:\s+<\S+>\s*$/i) || (defined($Header{'control'}) && $Header{'control'} =~ m/^Control:\s+cancel\s+<\S+>\s*$/i) ||(defined($Header{'also-control'}) && $Header{'also-control'} =~ m/^Also-Control:\s+cancel\s+<\S+>\s*$/i)) {
@@ -867,14 +867,14 @@ sub buildcancellock {
my $cancel_lock;
if ($config{'canlock_algorithm'} eq 'sha1') {
if ($sha_mod =~ m/SHA1/) {
- $cancel_lock = MIME::Base64::encode(Digest::SHA1::sha1($cancel_key, ''));
+ $cancel_lock = MIME::Base64::encode(Digest::SHA1::sha1($cancel_key, ''), '');
} else {
- $cancel_lock = MIME::Base64::encode(Digest::SHA::sha1($cancel_key, ''));
+ $cancel_lock = MIME::Base64::encode(Digest::SHA::sha1($cancel_key, ''), '');
}
} elsif ($config{'canlock_algorithm'} eq 'sha256') {
- $cancel_lock = MIME::Base64::encode(Digest::SHA::sha256($cancel_key, ''));
+ $cancel_lock = MIME::Base64::encode(Digest::SHA::sha256($cancel_key, ''), '');
} else {
- $cancel_lock = MIME::Base64::encode(Digest::SHA::sha512($cancel_key, ''));
+ $cancel_lock = MIME::Base64::encode(Digest::SHA::sha512($cancel_key, ''), '');
}
return $cancel_lock;
}
--tKW2IUtsqtDRztdT
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KdGluLWRldiBt
YWlsaW5nIGxpc3QKdGluLWRldkB0aW4ub3JnCmh0dHA6Ly9saXN0cy50aW4ub3JnL2NnaS1iaW4v
bWFpbG1hbi9saXN0aW5mby90aW4tZGV2Cg==
--tKW2IUtsqtDRztdT--