summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorGeLiXin <[email protected]>2016-10-01 06:40:07 +0800
committerBrian Behlendorf <[email protected]>2016-09-30 15:40:07 -0700
commited3ea30fb9341c860c94bf71e771f115ee4801ea (patch)
tree524a0b15122fed6e8cf76d907e9149cc2d0f3df0 /cmd
parent292d573e70d254f5011f20f0c4882e928fac594b (diff)
Fix coverity defects: CID 147536, 147537, 147538
coverity scan CID:147536, type: Argument cannot be negative - may write or close fd which is negative coverity scan CID:147537, type: Argument cannot be negative - may call dup2 with a negative fd coverity scan CID:147538, type: Argument cannot be negative - may read or fchown with a negative fd Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: GeLiXin <[email protected]> Closes #5185
Diffstat (limited to 'cmd')
-rwxr-xr-x[-rw-r--r--]cmd/zed/zed_exec.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd/zed/zed_exec.c b/cmd/zed/zed_exec.c
index 1d040ccd5..1a3b76d07 100644..100755
--- a/cmd/zed/zed_exec.c
+++ b/cmd/zed/zed_exec.c
@@ -106,10 +106,11 @@ _zed_exec_fork_child(uint64_t eid, const char *dir, const char *prog,
return;
} else if (pid == 0) {
(void) umask(022);
- fd = open("/dev/null", O_RDWR);
- (void) dup2(fd, STDIN_FILENO);
- (void) dup2(fd, STDOUT_FILENO);
- (void) dup2(fd, STDERR_FILENO);
+ if ((fd = open("/dev/null", O_RDWR)) != -1) {
+ (void) dup2(fd, STDIN_FILENO);
+ (void) dup2(fd, STDOUT_FILENO);
+ (void) dup2(fd, STDERR_FILENO);
+ }
(void) dup2(zfd, ZEVENT_FILENO);
zed_file_close_from(ZEVENT_FILENO + 1);
execle(path, prog, NULL, env);