Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
550779896a
2 zmenil súbory, kde vykonal 2 pridanie a 1 odobranie
  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
   * Fix segfault on update-alternatives when passing --slave without any
     action at all. LP: #1037431
     action at all. LP: #1037431
   * Fix memory leak in dpkg filesavespackage().
   * Fix memory leak in dpkg filesavespackage().
+  * Do not print garbage (or worse) on dpkg shared conffile debug output.
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * Czech (Miroslav Kure).
   * Czech (Miroslav Kure).

+ 1 - 1
src/archives.c

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