[dpkg] 165/192: Dpkg::Control::HashCore: Expect stanza delimiters more often than Armor Headers

Ximin Luo infinity0 at debian.org
Tue Oct 17 11:04:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit b56eddde1a625feff02ebfb92dff88c96f11d376
Author: Guillem Jover <guillem at debian.org>
Date:   Wed Sep 27 01:59:22 2017 +0200

    Dpkg::Control::HashCore: Expect stanza delimiters more often than Armor Headers
    
    Usually we will just have Armor Headers at the beginning and end of the
    data, so it's more common to find stanza delimiter lines. Optimize for
    that.
---
 debian/changelog                 |  2 ++
 scripts/Dpkg/Control/HashCore.pm | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 0079340..38a2a0b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -92,6 +92,8 @@ dpkg (1.19.0) UNRELEASED; urgency=medium
       in Dpkg::Vendor::Debian.
     - Do not use an intermediate variable in Dpkg::Control::HashCore::Tie
       STORE method.
+    - Expect deb822 stanza delimiters more often than OpenPGP Armor Headers
+      in Dpkg::Control::HashCore parse method.
   * Documentation:
     - Document currently accepted syntax for changelogs in deb-changelog(5).
       Closes: #858579
diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm
index 91b279d..a3ea4bc 100644
--- a/scripts/Dpkg/Control/HashCore.pm
+++ b/scripts/Dpkg/Control/HashCore.pm
@@ -227,16 +227,6 @@ sub parse {
 		$line = substr $line, 1;
 	    }
 	    $self->{$cf} .= "\n$line";
-	} elsif (m/^-----BEGIN PGP SIGNED MESSAGE-----[\r\t ]*$/) {
-	    $expect_pgp_sig = 1;
-	    if ($$self->{allow_pgp} and not $parabody) {
-		# Skip OpenPGP headers
-		while (<$fh>) {
-		    last if m/^\s*$/;
-		}
-	    } else {
-		$self->parse_error($desc, g_('OpenPGP signature not allowed here'));
-	    }
 	} elsif (m/^\s*$/ ||
 	         ($expect_pgp_sig && m/^-----BEGIN PGP SIGNATURE-----[\r\t ]*$/)) {
 	    if ($expect_pgp_sig) {
@@ -264,6 +254,16 @@ sub parse {
 		$$self->{is_pgp_signed} = 1;
 	    }
 	    last; # Finished parsing one block
+        } elsif (m/^-----BEGIN PGP SIGNED MESSAGE-----[\r\t ]*$/) {
+            $expect_pgp_sig = 1;
+            if ($$self->{allow_pgp} and not $parabody) {
+                # Skip OpenPGP headers
+                while (<$fh>) {
+                    last if m/^\s*$/;
+                }
+            } else {
+                $self->parse_error($desc, g_('OpenPGP signature not allowed here'));
+            }
 	} else {
 	    $self->parse_error($desc,
 	                       g_('line with unknown format (not field-colon-value)'));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list