Sfoglia il codice sorgente

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 15 anni fa
parent
commit
2c9a342dc4
2 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  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.
     status action exit codes.
   * Add start-stop-daemon process name kernel limits for Solaris, NetBSD,
   * Add start-stop-daemon process name kernel limits for Solaris, NetBSD,
     OpenBSD, FreeBSD and Darwin.
     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 ]
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
   * German (Sven Joachim). Closes: #620312

+ 2 - 1
src/help.c

@@ -474,7 +474,8 @@ hasdirectoryconffiles(struct filenamenode *file, struct pkginfo *pkg)
 	pkg->name);
 	pkg->name);
   namelen = strlen(file->name);
   namelen = strlen(file->name);
   for (conff= pkg->installed.conffiles; conff; conff= conff->next) {
   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",
 	debug(dbg_veryverbose, "directory %s has conffile %s from %s",
 	      file->name, conff->name, pkg->name);
 	      file->name, conff->name, pkg->name);
 	return true;
 	return true;