mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 07:42:56 +00:00
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).
This commit is contained in:
parent
f3cfc7c884
commit
746ff701e8
@ -492,6 +492,10 @@ virExecWithHook(const char *const*argv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pid) { /* parent */
|
if (pid) { /* parent */
|
||||||
|
if (forkRet < 0) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
VIR_FORCE_CLOSE(null);
|
VIR_FORCE_CLOSE(null);
|
||||||
if (outfd && *outfd == -1) {
|
if (outfd && *outfd == -1) {
|
||||||
VIR_FORCE_CLOSE(pipeout[1]);
|
VIR_FORCE_CLOSE(pipeout[1]);
|
||||||
@ -502,10 +506,6 @@ virExecWithHook(const char *const*argv,
|
|||||||
*errfd = pipeerr[0];
|
*errfd = pipeerr[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forkRet < 0) {
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
*retpid = pid;
|
*retpid = pid;
|
||||||
|
|
||||||
if (binary != argv[0])
|
if (binary != argv[0])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user