Просмотр исходного кода

libdpkg: Do not try to release the triggers lock on dry-run

We were installing a dummy cleanup handler, but removing it on some
error conditions when returning from trigdef_update_start(), but
trigdef_process_done() was expecting to always have a cleanup handler
to pop.

Reported-by: David Kalnischkies <david@kalnischkies.de>
Guillem Jover лет назад: 10
Родитель
Сommit
908261815d
2 измененных файлов с 8 добавлено и 6 удалено
  1. 2 0
      debian/changelog
  2. 6 6
      lib/dpkg/trigdeferred.l

+ 2 - 0
debian/changelog

@@ -19,6 +19,8 @@ dpkg (1.18.3) UNRELEASED; urgency=low
   * Switch dselect multicd method license from GPL2 to GPL2+, with consent
     from all its authors.
   * Fix inadvertent license change for lib/dpkg/utils.c from GPL2 to GPL2+.
+  * Fix segfault when using «dpkg --no-act» with a synthetic --admindir.
+    Reported by David Kalnischkies <david@kalnischkies.de>.
   * Perl modules:
     - Only warn on invalid week days instead of aborting in
       Dpkg::Changelog::Entry::Debian. Regression introduced in dpkg 1.18.2.

+ 6 - 6
lib/dpkg/trigdeferred.l

@@ -139,9 +139,6 @@ trigdef_update_start(enum trigdef_update_flags uf)
 		}
 
 		file_lock(&lock_fd, FILE_LOCK_WAIT, fn.buf, _("triggers area"));
-	} else {
-		/* Dummy for pop_cleanups. */
-		push_cleanup(NULL, 0, NULL, 0, 0);
 	}
 
 	constructfn(&fn, triggersdir, TRIGGERSDEFERREDFILE);
@@ -154,7 +151,8 @@ trigdef_update_start(enum trigdef_update_flags uf)
 			ohshite(_("unable to open triggers deferred file '%.250s'"),
 			        fn.buf);
 		if (!(uf & TDUF_WRITE_IF_ENOENT)) {
-			pop_cleanup(ehflag_normaltidy);
+			if (uf & TDUF_WRITE)
+				pop_cleanup(ehflag_normaltidy);
 			return TDUS_ERROR_NO_DEFERRED;
 		}
 	} else {
@@ -169,7 +167,8 @@ trigdef_update_start(enum trigdef_update_flags uf)
 			        fn.buf);
 
 		if (stab.st_size == 0 && !(uf & TDUF_WRITE_IF_EMPTY)) {
-			pop_cleanup(ehflag_normaltidy);
+			if (uf & TDUF_WRITE)
+				pop_cleanup(ehflag_normaltidy);
 			return TDUS_ERROR_EMPTY_DEFERRED;
 		}
 	}
@@ -245,5 +244,6 @@ trigdef_process_done(void)
 	triggersdir = NULL;
 
 	/* Unlock. */
-	pop_cleanup(ehflag_normaltidy);
+	if (lock_fd >= 0)
+		pop_cleanup(ehflag_normaltidy);
 }