[dpkg] 35/200: Dpkg::Deps: Validate architecture arguments in deps_parse()
Ximin Luo
infinity0 at debian.org
Wed Apr 5 15:17:11 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository dpkg.
commit d3d4348c31418fd2a392e148a880dce7db283d20
Author: Guillem Jover <guillem at debian.org>
Date: Sun Nov 13 17:54:59 2016 +0100
Dpkg::Deps: Validate architecture arguments in deps_parse()
This function only works with real and known Debian architectures. It
will not work with wildcards, nor the special architectures 'all' nor
'source'. Validate the arguments and croak early on to spot bogus usage.
Prompted-by: Johannes Schauer <josch at debian.org>
---
debian/changelog | 3 +++
scripts/Dpkg/Deps.pm | 9 ++++++++-
scripts/t/Dpkg_Deps.t | 21 ++++++++++++++++++++-
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 33f1ef9..ca712b4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ dpkg (1.18.15) UNRELEASED; urgency=medium
- Do not enable PIE when linking static programs. glibc-based systems
do not support this combination and produce very bogus output.
Proposed by Szabolcs Nagy <nsz at port70.net>. Closes: #843714
+ * Perl modules:
+ - Validate architecture arguments in Dpkg::Deps deps_parse().
+ Prompted by Johannes Schauer <josch at debian.org>.
* Test suite:
- Mark partially documented POD modules as TAP TODO.
diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 33d4411..e37e039 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -58,10 +58,11 @@ our @EXPORT = qw(
deps_compare
);
+use Carp;
use Exporter qw(import);
use Dpkg::Version;
-use Dpkg::Arch qw(get_host_arch get_build_arch);
+use Dpkg::Arch qw(get_host_arch get_build_arch debarch_to_debtuple);
use Dpkg::BuildProfiles qw(get_build_profiles);
use Dpkg::ErrorHandling;
use Dpkg::Gettext;
@@ -250,6 +251,12 @@ working with dependency fields from F<debian/tests/control>.
sub deps_parse {
my ($dep_line, %options) = @_;
+ # Validate arguments.
+ croak "invalid host_arch $options{host_arch}"
+ if defined $options{host_arch} and not defined debarch_to_debtuple($options{host_arch});
+ croak "invalid biuild_arch $options{build_arch}"
+ if defined $options{build_arch} and not defined debarch_to_debtuple($options{build_arch});
+
$options{use_arch} //= 1;
$options{reduce_arch} //= 0;
$options{host_arch} //= get_host_arch();
diff --git a/scripts/t/Dpkg_Deps.t b/scripts/t/Dpkg_Deps.t
index bb16ba2..71a3cf1 100644
--- a/scripts/t/Dpkg_Deps.t
+++ b/scripts/t/Dpkg_Deps.t
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 62;
+use Test::More tests => 70;
use Dpkg::Arch qw(get_host_arch);
use Dpkg::Version;
@@ -30,6 +30,25 @@ is(deps_concat('', undef), '', 'Concatenate empty string with undef');
is(deps_concat('dep-a', undef, 'dep-b'), 'dep-a, dep-b',
'Concatenate two strings with intermixed undef');
+sub test_dep_parse_option {
+ my %options = @_;
+
+ eval {
+ my $dep_croak = deps_parse('pkg', %options);
+ };
+ my $options = join ' ', map { "$_=$options{$_}" } keys %options;
+ ok(defined $@, "Parse with bogus arch options $options");
+}
+
+test_dep_parse_option(host_arch => 'all');
+test_dep_parse_option(host_arch => 'any');
+test_dep_parse_option(host_arch => 'linux-any');
+test_dep_parse_option(host_arch => 'unknown-arch');
+test_dep_parse_option(build_arch => 'all');
+test_dep_parse_option(build_arch => 'any');
+test_dep_parse_option(build_arch => 'linux-any');
+test_dep_parse_option(build_arch => 'unknown-arch');
+
my $field_multiline = ' , , libgtk2.0-common (= 2.10.13-1) , libatk1.0-0 (>=
1.13.2), libc6 (>= 2.5-5), libcairo2 (>= 1.4.0), libcupsys2 (>= 1.2.7),
libfontconfig1 (>= 2.4.0), libglib2.0-0 ( >= 2.12.9), libgnutls13 (>=
--
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