Browse Source

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 8 years ago
parent
commit
3456a88215
2 changed files with 5 additions and 0 deletions
  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
   * Use ohshit() instead of internerr() for unhandled dpkg-split exit codes.
     (i.e. do not abort). Closes: #812679
+  * Detect non-regular file archive arguments earlier in dpkg.
   * Perl modules:
     - Add new CTRL_REPO_RELEASE control block type to Dpkg::Control.
     - 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. */
     if (stat(argp[i], &st) < 0)
       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);