Преглед изворни кода

libdpkg: Use execvp(3) unconditionally in command_exec()

execvp(3) already checks if its file argument contains a '/'; simplify
by not checking again for the same thing.

The real motivation is to avoid confusing behavior in an edge case:
when execve(2) fails with ENOEXEC, execvp will run the script using the
system shell but execv will error out.

Closes: #622094

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Guillem Jover <guillem@debian.org>
Jonathan Nieder пре 15 година
родитељ
комит
e654cb5b6d
2 измењених фајлова са 5 додато и 4 уклоњено
  1. 4 0
      debian/changelog
  2. 1 4
      lib/dpkg/command.c

+ 4 - 0
debian/changelog

@@ -12,6 +12,10 @@ dpkg (1.16.1) UNRELEASED; urgency=low
   * Document in dpkg-query(1) man page that on --listfiles each list of
     files per package name is separated by a blank line. Same goes for
     --status and --print-avail.
+  * Use execvp(3) unconditionally in command_exec(). Making the call always
+    fallback to use the system shell in case of error, such as with empty
+    maintainer scripts. Thanks to Jonathan Nieder <jrnieder@gmail.com>.
+    Closes: #622094
 
   [ Updated man page translations ]
   * German (Helge Kreutzmann).

+ 1 - 4
lib/dpkg/command.c

@@ -175,10 +175,7 @@ command_add_args(struct command *cmd, ...)
 void
 command_exec(struct command *cmd)
 {
-	if (strchr(cmd->filename, '/'))
-		execv(cmd->filename, (char * const *)cmd->argv);
-	else
-		execvp(cmd->filename, (char * const *)cmd->argv);
+	execvp(cmd->filename, (char * const *)cmd->argv);
 	ohshite(_("unable to execute %s (%s)"), cmd->name, cmd->filename);
 }