Control: tag -1 + patch

I recently stumbled over this missing feature and was finally annoyed
enough to prepare a patch. I didn't remember though that back then I
already reported a bug. Anyhow, here comes a patch that works fine for
me:

-------->8---------
gpgsigs: Properly handle prefilled checksums

gpgsigs applied to the output of gpgparticipants-prefill(1) now detects
the prefilled characters and handles that accordingly instead of failing
with "Skipping $algo digest value (invalid fill-in length)".

Closes: #900444

diff --git a/gpgsigs/gpgsigs b/gpgsigs/gpgsigs
index 737c6ecd3423..379f937b770f 100755
--- a/gpgsigs/gpgsigs
+++ b/gpgsigs/gpgsigs
@@ -402,6 +402,13 @@ while (<TXT>) {
                                $_ = <TXT>;
                                $r .= $_;
                        }
+                       $r =~ /^(?:\S+) Checksum:\s*([0-9a-fA-F\s]*)/;
+                       my $prefill = $1;
+                       if ($prefill) {
+                               # Replace the prefilled value by underscores 
for the following replacement
+                               my $emptyprefill = $prefill =~ 
s/[0-9a-fA-F]/_/rg;
+                               $r =~ s/\Q$prefill\E/$emptyprefill/;
+                       }
                        my $n = $r =~ y/_//;
                        my $k = $n / length($md);
                        if (int($k) * length($md) != $n) {
@@ -410,6 +417,10 @@ while (<TXT>) {
                                my $w = '_' x $k;
                                $r =~ s/\Q$w\E/%c/g;
                                $r = sprintf($r, unpack ("C*", $md));
+
+                               if ($prefill and $r !~ /^(?:\S+) 
Checksum:\s*\Q$prefill\E/i) {
+                                       warn "Wrong prefill for $algo digest 
value\n";
+                               }
                        }
                        print WRITE $r;
                        next;

Best regards
Uwe

Attachment: signature.asc
Description: PGP signature

Reply via email to