Selaa lähdekoodia

dpkg: Do not print garbage (or worse) on shared conffile debug output

The variable was being initialized after the debug statement, and if
there was no NUL terminator the code could access out of bounds memory.
Guillem Jover 14 vuotta sitten
vanhempi
commit
550779896a
2 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  1. 1 0
      debian/changelog
  2. 1 1
      src/archives.c

+ 1 - 0
debian/changelog

@@ -20,6 +20,7 @@ dpkg (1.16.9) UNRELEASED; urgency=low
   * Fix segfault on update-alternatives when passing --slave without any
     action at all. LP: #1037431
   * Fix memory leak in dpkg filesavespackage().
+  * Do not print garbage (or worse) on dpkg shared conffile debug output.
 
   [ Updated programs translations ]
   * Czech (Miroslav Kure).

+ 1 - 1
src/archives.c

@@ -201,11 +201,11 @@ md5hash_prev_conffile(struct pkginfo *pkg, char *oldhash, const char *oldname,
         break;
     }
     if (conff) {
+      strcpy(oldhash, conff->hash);
       debug(dbg_conffdetail,
             "tarobject found shared conffile, from pkg %s (%s); hash=%s",
             pkg_name(otherpkg, pnaw_always),
             statusinfos[otherpkg->status].name, oldhash);
-      strcpy(oldhash, conff->hash);
       break;
     }
   }