summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-08-15 09:39:00 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2019-08-15 09:45:29 +0200
commit9fdcaee218505710495fea35f3b8538bebeaa1f9 (patch)
tree8664579d6a5e8158396812aba99d68db93bd5357 /apt-pkg/acquire.cc
parented4a8421e4d51c19a4aa1bd5e91370ba8bc8efca (diff)
Fix segfault in pkgAcquire::Enqueue() with Acquire::Queue-Mode=access
In commit 79b1a8298, QueueName() was changed, amongst other things, to exit early when the queue mode was single access, as single access does not need any fancy queue name. The exit became too early though, as Config was not initialized anymore, but the caller was relying on it. Fix QueueName() to always initialize Config and in Enqueue() initialize Config with a nullptr, so if this regresses it's guaranteed to fail harder. Also add a test case - this is very simple, but the first and only test case for access queue mode. Regression-Of: 79b1a82983e737e74359bc306d9edb357c5bdd46 LP: #1839714
Diffstat (limited to 'apt-pkg/acquire.cc')
-rw-r--r--apt-pkg/acquire.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 6cf8b4c83..776c82b3b 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -307,7 +307,7 @@ static bool CheckForBadItemAndFailIt(pkgAcquire::Item * const Item,
void pkgAcquire::Enqueue(ItemDesc &Item)
{
// Determine which queue to put the item in
- const MethodConfig *Config;
+ const MethodConfig *Config = nullptr;
string Name = QueueName(Item.URI,Config);
if (Name.empty() == true)
{
@@ -387,14 +387,16 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
{
constexpr int DEFAULT_HOST_LIMIT = 10;
URI U(Uri);
- // Access mode forces all methods to be Single-Instance
- if (QueueMode == QueueAccess)
- return U.Access;
+ // Note that this gets written through the reference to the caller.
Config = GetConfig(U.Access);
if (Config == nullptr)
return {};
+ // Access mode forces all methods to be Single-Instance
+ if (QueueMode == QueueAccess)
+ return U.Access;
+
// Single-Instance methods get exactly one queue per URI
if (Config->SingleInstance == true)
return U.Access;