Pārlūkot izejas kodu

dpkg: Detect non-regular file archive arguments earlier

We cannot handle anything else that is not a regular file (excluding
symlinks to them), so detect this earlier and error out in such case.
Guillem Jover 10 gadi atpakaļ
vecāks
revīzija
3456a88215
2 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 1 0
      debian/changelog
  2. 4 0
      src/archives.c

+ 1 - 0
debian/changelog

@@ -12,6 +12,7 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
     Closes: #809963
     Closes: #809963
   * Use ohshit() instead of internerr() for unhandled dpkg-split exit codes.
   * Use ohshit() instead of internerr() for unhandled dpkg-split exit codes.
     (i.e. do not abort). Closes: #812679
     (i.e. do not abort). Closes: #812679
+  * Detect non-regular file archive arguments earlier in dpkg.
   * Perl modules:
   * Perl modules:
     - Add new CTRL_REPO_RELEASE control block type to Dpkg::Control.
     - Add new CTRL_REPO_RELEASE control block type to Dpkg::Control.
     - Add new CTRL_COPYRIGHT_HEADER, CTRL_COPYRIGHT_FILES and
     - Add new CTRL_COPYRIGHT_HEADER, CTRL_COPYRIGHT_FILES and

+ 4 - 0
src/archives.c

@@ -1512,6 +1512,10 @@ archivefiles(const char *const *argv)
     /* We need the filename to exist. */
     /* We need the filename to exist. */
     if (stat(argp[i], &st) < 0)
     if (stat(argp[i], &st) < 0)
       ohshite(_("cannot access archive '%s'"), argp[i]);
       ohshite(_("cannot access archive '%s'"), argp[i]);
+
+    /* We cannot work with anything that is not a regular file. */
+    if (!S_ISREG(st.st_mode))
+      ohshit(_("archive '%s' is not a regular file"), argp[i]);
   }
   }
 
 
   currenttime = time(NULL);
   currenttime = time(NULL);