summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/cacheset.cc6
-rwxr-xr-xtest/integration/test-ubuntu-bug-365611-long-package-names6
2 files changed, 9 insertions, 3 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;
diff --git a/test/integration/test-ubuntu-bug-365611-long-package-names b/test/integration/test-ubuntu-bug-365611-long-package-names
index 894c8dc97..f22986e21 100755
--- a/test/integration/test-ubuntu-bug-365611-long-package-names
+++ b/test/integration/test-ubuntu-bug-365611-long-package-names
@@ -4,8 +4,12 @@ set -e
TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
setupenvironment
-configarchitecture "i386"
+configarchitecture 'i386'
setupaptarchive
aptget install $(for i in $(seq 0 1000); do echo -n 'a'; done) 2> longpackagename.log > /dev/null || true
testfileequal 'longpackagename.log' "E: Unable to locate package $(for i in $(seq 0 1000); do echo -n 'a'; done)"
+
+# … and the opposite of long:
+aptget install "" -s >longpackagename.log 2>&1 || true
+testfileequal 'longpackagename.log' "$(aptget install -s)"