summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-05-20 09:37:24 +0200
committerJulian Andres Klode <jak@debian.org>2016-05-20 19:48:33 +0200
commitcde5b485c9cdf0bfd5b6ea8e4973abe378270e60 (patch)
tree7b6de7936e1fe5a1f05aa012a6dac475f4a40ef3 /apt-pkg
parent235347e50c61be5e1813c1a3bbcdd98e61ae57a7 (diff)
fail instead of segfault on unreadable config files
The report mentions "apt list --upgradable", but there are others which have inconsistent behavior ranging from segfaulting to doing something with the partial (and hence incomplete) data. We had a recent report about sources.list (#818628), this one mentions prefences, the obvious next step is conf files… so the testcase is adapted to check for all three in file and directory versions and run a bunch of commands each time which should all have more or less the same behavior in such a case (aka error out). Closes: 824503 (cherry picked from commit fdf9eef4d96a18d0167708499c993e1174251e88)
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cachefile.cc3
-rw-r--r--apt-pkg/policy.cc5
2 files changed, 8 insertions, 0 deletions
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 0e2192973..b5f32fc29 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -173,6 +173,9 @@ bool pkgCacheFile::BuildPolicy(OpProgress * /*Progress*/)
/* */
bool pkgCacheFile::BuildDepCache(OpProgress *Progress)
{
+ if (BuildCaches(Progress, false) == false)
+ return false;
+
std::unique_ptr<pkgDepCache> DCache;
if (this->DCache != NULL)
return true;
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index b36f4d4b7..06c516e53 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -414,7 +414,12 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir)
return true;
}
+ _error->PushToStack();
vector<string> const List = GetListOfFilesInDir(Dir, "pref", true, true);
+ bool const PendingErrors = _error->PendingError();
+ _error->MergeWithStack();
+ if (PendingErrors)
+ return false;
// Read the files
for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)