]> git.saurik.com Git - apt.git/commitdiff
Do not crash for apt-get install /dev/null
authorMichael Vogt <mvo@debian.org>
Wed, 16 Jul 2014 13:48:05 +0000 (15:48 +0200)
committerMichael Vogt <mvo@debian.org>
Wed, 16 Jul 2014 13:50:52 +0000 (15:50 +0200)
Thanks to Jakub Wilk for the bugreport.

Closes: #754904
apt-pkg/cacheset.cc
test/integration/test-apt-get-install-deb [new file with mode: 0755]

index 346bad3aaa3a587f0fc6b0202be534a4e8e76929..d95a32aff110d617343085a5dce733bd7de188c5 100644 (file)
@@ -450,6 +450,8 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
         if(FileExists(pkg))
         {
                 PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
+                if(pkgset.size() == 0)
+                   return false;
                 return VersionContainerInterface::FromPackage(vci, Cache, pkgset.begin(), fallback, helper);
         }
 
diff --git a/test/integration/test-apt-get-install-deb b/test/integration/test-apt-get-install-deb
new file mode 100755 (executable)
index 0000000..700009d
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+# regression test for #754904
+testequal 'E: Unable to locate package /dev/null' aptget install -qq /dev/null
+
+# and ensure we fail for invalid debs
+cat > foo.deb <<EOF
+I'm not a deb, I'm a teapot.
+EOF
+testequal 'E: Sub-process Popen returned an error code (100)
+E: Encountered a section with no Package: header
+E: Problem with MergeLister for ./foo.deb
+E: The package lists or status file could not be parsed or opened.' aptget install -qq ./foo.deb
+
+# fakeroot is currently not found, framwork needs updating
+#
+#buildsimplenativepackage 'foo' 'all' '1.0' 
+#
+#testequal 'Selecting previously unselected package foo.
+#(Reading database ... 0 files and directories currently installed.)
+# Preparing to unpack .../incoming/foo_1.0_all.deb ...
+#Unpacking foo (1.0) ...
+#Setting up foo (1.0) ...' aptget install -qq ./incoming/foo_1.0_all.deb