summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/deblistparser.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2017-02-10 22:39:00 +0100
committerJulian Andres Klode <jak@debian.org>2017-02-10 23:12:52 +0100
commit85ee4036c68d8ecd2c973d413a17aca81380900b (patch)
tree103e5302ec379461ca91aa74f59e319b09f644d4 /apt-pkg/deb/deblistparser.cc
parent89a2e40d14c29c66aead51df0d56c5c49776009a (diff)
Do not package names representing .dsc/.deb/... files
In the case of build-dep and other commands where a file can be passed we must make sure not to normalize the path name as that can have odd side effects, or well, cause the operation to do nothing. Test for build-dep-file is adjusted to perform the vcard check once as "vcard" and once as "VCard", thus testing that this solves the reported bug. We inline the std::transform() and optimize it a bit to not write anything in the common case (package names are defined to be lowercase, the whole transformation is just for names that should not exist...) to counter the performance hit of the added find() call (it's about 0.15% more instructions than with the existing transform, but we save about 0.67% in writes...). Closes: #854794
Diffstat (limited to 'apt-pkg/deb/deblistparser.cc')
-rw-r--r--apt-pkg/deb/deblistparser.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index cf0a9a402..4e61f0fc2 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -72,8 +72,19 @@ string debListParser::Package() {
string Result = Section.Find(pkgTagSection::Key::Package).to_string();
// Normalize mixed case package names to lower case, like dpkg does
- // See Bug#807012 for details
- std::transform(Result.begin(), Result.end(), Result.begin(), tolower_ascii);
+ // See Bug#807012 for details.
+ // Only do this when the package name does not contain a / - as that
+ // indicates that the package name was derived from a filename given
+ // to install or build-dep or similar (Bug#854794)
+ if (likely(Result.find('/') == string::npos))
+ {
+ for (char &c: Result)
+ {
+ char l = tolower_ascii_inline(c);
+ if (unlikely(l != c))
+ c = l;
+ }
+ }
if(unlikely(Result.empty() == true))
_error->Error("Encountered a section with no Package: header");