Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
run-command: dup_devnull(): guard against syscalls failing
author
Thomas Rast
<trast@inf.ethz.ch>
Fri, 12 Jul 2013 08:58:36 +0000
(10:58 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 12 Jul 2013 17:30:09 +0000
(10:30 -0700)
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>
run-command.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
a2cb86c
)
diff --git
a/run-command.c
b/run-command.c
index 04712191e8acfbf000c526a5b1b0a80541e8e174..afc573ed41061f7c704209de2d229e7a6a900165 100644
(file)
--- 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