[tin-dev] [PATCH] tinews.pl: Cancel-Lock with sha512 gets truncated

Dennis Preiser dennis at d--p.de
Thu Sep 21 21:36:45 CEST 2017


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
-------------- next part --------------
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;
 }


More information about the tin-dev mailing list