提交 0e4efa3d 编写于 作者: W Wen Congyang 提交者: Cole Robinson

command: check for fork error before closing fd

We should not set *outfd or *errfd if virExecWithHook() failed
because the caller may close these fds.

Bug present since v0.4.5 (commit 60ed1d2a).
(cherry picked from commit 746ff701)
上级 26ceca4b
......@@ -394,6 +394,10 @@ virExecWithHook(const char *const*argv,
}
if (pid) { /* parent */
if (forkRet < 0) {
goto cleanup;
}
VIR_FORCE_CLOSE(null);
if (outfd && *outfd == -1) {
VIR_FORCE_CLOSE(pipeout[1]);
......@@ -404,10 +408,6 @@ virExecWithHook(const char *const*argv,
*errfd = pipeerr[0];
}
if (forkRet < 0) {
goto cleanup;
}
*retpid = pid;
if (binary != argv[0])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册