diff options
author | Guillem Jover <guillem@debian.org> | 2013-07-25 03:31:01 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2013-07-26 23:53:33 +0200 |
commit | bb38862b4a6232b89f5f20abbb5d20756b34d4d6 (patch) | |
tree | ac27318230ef7b902b06d24cd9eb18b9a9e49051 | |
parent | 649c745f7ea21ec2628e2b039c7590f3934d7195 (diff) | |
download | dpkg-bb38862b4a6232b89f5f20abbb5d20756b34d4d6.tar.gz |
Dpkg::Source::Package: Do not scan control file twice for PGP signature
The code was pre-scanning the control file looking for a PGP signature,
and the parser was doing a more thorough check later on. Just remove the
double parsing, and rely on the more accurate one from the parser.
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | scripts/Dpkg/Control/HashCore.pm | 6 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package.pm | 10 |
3 files changed, 5 insertions, 12 deletions
diff --git a/debian/changelog b/debian/changelog index 193cf7a27..7f52af054 100644 --- a/debian/changelog +++ b/debian/changelog @@ -140,6 +140,7 @@ dpkg (1.17.0) UNRELEASED; urgency=low which might be problematic when cross-compiling. Closes: #698881 * Only apply empy line and comma cleanups when doing substvar replacements on fields where those are relevant. Closes: #659814 + * Do not scan control files twice for PGP signature presence. [ Raphaƫl Hertzog ] * Fix dpkg-maintscript-helper rm_conffile and mv_conffile to do nothing diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index 236e111b4..51cfc5a33 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -105,6 +105,7 @@ sub new { my $self = \{ in_order => [], out_order => [], + is_pgp_signed => 0, allow_pgp => 0, allow_duplicate => 0, drop_empty => 0, @@ -172,7 +173,6 @@ sub parse { my $parabody = 0; my $cf; # Current field my $expect_pgp_sig = 0; - my $pgp_signed = 0; while (<$fh>) { s/\s*\n$//; @@ -229,7 +229,7 @@ sub parse { } # This does not mean the signature is correct, that needs to # be verified by gnupg. - $pgp_signed = 1; + $$self->{is_pgp_signed} = 1; } last; # Finished parsing one block } else { @@ -238,7 +238,7 @@ sub parse { } } - if ($expect_pgp_sig and not $pgp_signed) { + if ($expect_pgp_sig and not $$self->{is_pgp_signed}) { syntaxerr($desc, _g('unfinished PGP signature')); } diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 0d510fbad..3472f4463 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -189,19 +189,11 @@ sub initialize { $self->{basedir} = $dir || './'; $self->{filename} = $fn; - # Check if it contains a signature - open(my $dsc_fh, '<', $filename) || syserr(_g('cannot open %s'), $filename); - $self->{is_signed} = 0; - while (<$dsc_fh>) { - next if /^\s*$/o; - $self->{is_signed} = 1 if /^-----BEGIN PGP SIGNED MESSAGE-----\s*$/o; - last; - } - close($dsc_fh); # Read the fields my $fields = Dpkg::Control->new(type => CTRL_PKG_SRC); $fields->load($filename); $self->{fields} = $fields; + $self->{is_signed} = $fields->get_option('is_pgp_signed'); foreach my $f (qw(Source Version Files)) { unless (defined($fields->{$f})) { |