diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-04-21 13:26:55 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-04-26 09:51:05 +0200 |
commit | d99854cac4065bc7b337815fb2116269d58dab73 (patch) | |
tree | 70da8273517b7ffb025aa47862c26f7fd6d54480 /apt-pkg | |
parent | 7187074bfc7a6932ab21c33546e71b61abe258e3 (diff) |
handle pkgnames shorter than modifiers
The bugreport highlights the problem with an empty package name. We fix
this by 'ignoring' these so that it behaves just like "apt-get install".
The deeper problem is that modifier strings can be longer than a package
name in which case the comparison doesn't make sense, so don't compare
then. Was not noticed so far as all modifiers are of length 1, so the
only package name shorter than this is in fact the empty package name.
Closes: 744940
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/cacheset.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index d453a2bfb..2ed6a96da 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -391,6 +391,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID, CacheSetHelper &helper) { Version select = NEWEST; std::string str = cmdline; + if (unlikely(str.empty() == true)) + return false; bool modifierPresent = false; unsigned short fallback = modID; for (std::list<Modifier>::const_iterator mod = mods.begin(); @@ -400,8 +402,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID, size_t const alength = strlen(mod->Alias); switch(mod->Pos) { case Modifier::POSTFIX: - if (str.compare(str.length() - alength, alength, - mod->Alias, 0, alength) != 0) + if (str.length() <= alength || + str.compare(str.length() - alength, alength, mod->Alias, 0, alength) != 0) continue; str.erase(str.length() - alength); modID = mod->ID; |