Parcourir la source

dpkg: Fix wrong matching for check on directory containing conffiles

On package removal, keep only directories actually containing conffiles,
and not directories just matching the substring in the conffile or the
directory itself. The directory itself is not matched either as strictly
speaking it is not contained in itself, and it should already be in the
leftover lists.

Previously when checking for directory ‘/foo’ the following conffiles
would match:

  /foo
  /foobar
  /foo/bar

Now only the following will match:

  /foo/bar

Spotted-by: Ondřej Surý <ondrej@debian.org>
Guillem Jover il y a 15 ans
Parent
commit
2c9a342dc4
2 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 3 0
      debian/changelog
  2. 2 1
      src/help.c

+ 3 - 0
debian/changelog

@@ -51,6 +51,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     status action exit codes.
   * Add start-stop-daemon process name kernel limits for Solaris, NetBSD,
     OpenBSD, FreeBSD and Darwin.
+  * On package removal, keep only directories actually containing conffiles,
+    and not directories just matching the substring in the conffile or the
+    directory itself. Thanks to Ondřej Surý <ondrej@debian.org>.
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312

+ 2 - 1
src/help.c

@@ -474,7 +474,8 @@ hasdirectoryconffiles(struct filenamenode *file, struct pkginfo *pkg)
 	pkg->name);
   namelen = strlen(file->name);
   for (conff= pkg->installed.conffiles; conff; conff= conff->next) {
-      if (!strncmp(file->name,conff->name,namelen)) {
+      if (strncmp(file->name, conff->name, namelen) == 0 &&
+          conff->name[namelen] == '/') {
 	debug(dbg_veryverbose, "directory %s has conffile %s from %s",
 	      file->name, conff->name, pkg->name);
 	return true;