Prechádzať zdrojové kódy

dpkg-deb, dpkg: Do not allow pathnames with embedded newlines

None of the deb toolchain supports embedded newlines in filenames, we
could try to escape them but then we'd need to add support in other
tools to unescape these too, and this does not sem worth the trouble.

Closes: #720761
Guillem Jover 11 rokov pred
rodič
commit
438db7a31e
3 zmenil súbory, kde vykonal 8 pridanie a 0 odobranie
  1. 2 0
      debian/changelog
  2. 2 0
      dpkg-deb/build.c
  3. 4 0
      src/archives.c

+ 2 - 0
debian/changelog

@@ -3,6 +3,8 @@ dpkg (1.18.1) UNRELEASED; urgency=low
   [ Guillem Jover ]
   * Cast c_isbits() c argument to an unsigned char when indexing the array.
     This fixes build failures on armel, armhf, ppc64el and s390x.
+  * Do not allow pathnames with embedded newlines in dpkg-deb and dpkg.
+    Closes: #720761
 
   [ Updated programs translations ]
   * German (Sven Joachim).

+ 2 - 0
dpkg-deb/build.c

@@ -194,6 +194,8 @@ file_treewalk_feed(const char *dir, int fd_out)
   /* We need to reorder the files so we can make sure that symlinks
    * will not appear before their target. */
   while ((fi = file_info_get(dir, pipefd[0])) != NULL) {
+    if (strchr(fi->fn, '\n'))
+      ohshit(_("newline not allowed in pathname '%s'"), fi->fn);
     if (S_ISLNK(fi->st.st_mode)) {
       file_info_list_append(&symlist, &symlist_end, fi);
     } else {

+ 4 - 0
src/archives.c

@@ -658,6 +658,10 @@ tarobject(void *ctx, struct tar_entry *ti)
 
   tar_entry_update_from_system(ti);
 
+  /* Perform some sanity checks on the tar entry. */
+  if (strchr(ti->name, '\n'))
+    ohshit(_("newline not allowed in archive object name '%.255s'"), ti->name);
+
   /* Append to list of files.
    * The trailing ‘/’ put on the end of names in tarfiles has already
    * been stripped by tar_extractor(). */