[Reproducible-commits] [dpkg] 03/04: Dpkg::Source::Patch: Outright reject C-style filenames in patches
Holger Levsen
holger at layer-acht.org
Tue May 3 08:43:46 UTC 2016
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to annotated tag 1.16.14
in repository dpkg.
commit d49704f7fd699e809aead799a1dd4d20d969665a
Author: Guillem Jover <guillem at debian.org>
Date: Wed Apr 30 02:28:45 2014 +0200
Dpkg::Source::Patch: Outright reject C-style filenames in patches
Cherry picked from commit a12eb58959d0a10584a428f4a3103a49204c410f.
Because patch only started recognizing C-style filenames in diffs
in version 2.7, it's not safe to assume one behaviour or the other,
as the system might or might not have a recent enough version, or
a GNU patch program at all. There's also no reason we should be
supporting this kind of strange encoded filenames in patches, when
we have not done so up to now.
Let's just ban these types of diffs and be done with it.
Fixes: CVE-2014-0471
Closes: #746306
---
debian/changelog | 4 ++++
scripts/Dpkg/Source/Patch.pm | 32 +-------------------------------
2 files changed, 5 insertions(+), 31 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index c19f42f..1a65e57 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,9 @@
dpkg (1.16.14) UNRELEASED; urgency=low
+ [ Guillem Jover ]
+ * Do not allow patch files with C-style encoded filenames. Closes: #746306
+ Unconditionally fixes CVE-2014-0471.
+
[ Updated scripts translations ]
* German (Helge Kreutzmann).
diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm
index d9b084e..ce29d5f 100644
--- a/scripts/Dpkg/Source/Patch.pm
+++ b/scripts/Dpkg/Source/Patch.pm
@@ -310,31 +310,6 @@ sub _fail_not_same_type {
$self->register_error();
}
-my %ESCAPE = ((
- 'a' => "\a",
- 'b' => "\b",
- 'f' => "\f",
- 'n' => "\n",
- 'r' => "\r",
- 't' => "\t",
- 'v' => "\cK",
- '\\' => "\\",
- '"' => "\"",
-), (
- map { sprintf('%03o', $_) => chr($_) } (0..255)
-));
-
-sub _unescape {
- my ($diff, $str) = @_;
-
- if (exists $ESCAPE{$str}) {
- return $ESCAPE{$str};
- } else {
- error(_g("diff %s patches file with unknown escape sequence \\%s"),
- $diff, $str);
- }
-}
-
# Fetch the header filename ignoring the optional timestamp
sub _fetch_filename {
my ($diff, $header) = @_;
@@ -344,12 +319,7 @@ sub _fetch_filename {
# Is it a C-style string?
if ($header =~ m/^"/) {
- $header =~ m/^"((?:[^\\"]|\\.)*)"/;
- error(_g('diff %s patches file with unbalanced quote'), $diff)
- unless defined $1;
-
- $header = $1;
- $header =~ s/\\([0-3][0-7]{2}|.)/_unescape($diff, $1)/eg;
+ error(_g('diff %s patches file with C-style encoded filename'), $diff);
} else {
# Tab is the official separator, it's always used when
# filename contain spaces. Try it first, otherwise strip on space
--
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