From 79f012bd09ae99d4c9d63dc0ac960376b5338b32 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 13 Jun 2018 18:45:12 +0200 Subject: Fix lock counting in debSystem debSystem uses a reference counted lock, so you can acquire it multiple times in your applications, possibly nested. Nesting locks causes a fd leak, though, as we only increment the lock count when we already have locked twice, rather than once, and hence when we call lock the second time, instead of increasing the lock count, we open another lock fd. This fixes the code to check if we have locked at all (> 0). There is no practical problem here aside from the fd leak, as closing the new fd releases the lock on the old one due to the weird semantics of fcntl locks. --- apt-pkg/deb/debsystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index b620d889a..c183ab000 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -77,7 +77,7 @@ debSystem::~debSystem() bool debSystem::Lock() { // Disable file locking - if (_config->FindB("Debug::NoLocking",false) == true || d->LockCount > 1) + if (_config->FindB("Debug::NoLocking",false) == true || d->LockCount > 0) { d->LockCount++; return true; -- cgit v1.2.3