summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorThomas Rast <trast@inf.ethz.ch>2013-07-12 08:58:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-07-12 17:30:09 (GMT)
commita77f106c7837faf6a712ea3ac720f5c4fa2feb07 (patch)
tree15ecb20533e86b9c215a1b94796ba476fb3ac249 /run-command.c
parenta2cb86c1524b7af20e609ca8d3db0b60b5c1d575 (diff)
downloadgit-a77f106c7837faf6a712ea3ac720f5c4fa2feb07.zip
git-a77f106c7837faf6a712ea3ac720f5c4fa2feb07.tar.gz
git-a77f106c7837faf6a712ea3ac720f5c4fa2feb07.tar.bz2
run-command: dup_devnull(): guard against syscalls failing
dup_devnull() did not check the return values of open() and dup2(). Fix this omission. Signed-off-by: Thomas Rast <trast@inf.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/run-command.c b/run-command.c
index 0471219..afc573e 100644
--- a/run-command.c
+++ b/run-command.c
@@ -76,7 +76,10 @@ static inline void close_pair(int fd[2])
static inline void dup_devnull(int to)
{
int fd = open("/dev/null", O_RDWR);
- dup2(fd, to);
+ if (fd < 0)
+ die_errno(_("open /dev/null failed"));
+ if (dup2(fd, to) < 0)
+ die_errno(_("dup2(%d,%d) failed"), fd, to);
close(fd);
}
#endif