From 49f9cfba5567cd034bf729a63b3f6e9badd9bc35 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 31 Aug 2022 16:26:48 +0200 Subject: Report failures back from debSystem::AddStatusFiles Failing to properly create the status file class should be reported back to the caller so it can proceed accordingly instead of proceeding into more failures. This gives us: E: flAbsPath on /var/lib/dpkg/status failed - realpath (2: No such file or directory) E: The package lists or status file could not be parsed or opened. instead of: E: flAbsPath on /var/lib/dpkg/status failed - realpath (2: No such file or directory) E: Could not open file - open (2: No such file or directory) E: Problem opening E: The package lists or status file could not be parsed or opened. and valgrind reporting actions on uninitialised values. --- apt-pkg/deb/debsystem.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index c9c6a7e85..65a27f72f 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -335,8 +335,20 @@ signed debSystem::Score(Configuration const &Cnf) /* */ bool debSystem::AddStatusFiles(std::vector &List) { - if (d->StatusFile == 0) - d->StatusFile = new debStatusIndex(_config->FindFile("Dir::State::status")); + if (d->StatusFile == nullptr) + { + auto dpkgstatus = _config->FindFile("Dir::State::status"); + _error->PushToStack(); + d->StatusFile = new debStatusIndex(std::move(dpkgstatus)); + bool const errored = _error->PendingError(); + _error->MergeWithStack(); + if (errored) + { + delete d->StatusFile; + d->StatusFile = nullptr; + return false; + } + } List.push_back(d->StatusFile); return true; } -- cgit v1.2.3-70-g09d2