util: Fix bug which will cause libvirtd crash

"virCommandRun": if "cmd->outbuf" or "cmd->errbuf" is NULL,
libvirtd will be crashed when trying to start a qemu domain
(which invokes "virCommandRun"), it caused by we try to use
"*cmd->outbuf" and "*cmd->errbuf" regardless of cmd->outbuf
or cmd->errbuf is NULL.

* src/util/command.c (virCommandRun)
This commit is contained in:
Osier Yang 2010-12-06 17:41:10 +08:00 committed by Eric Blake
parent 58d0f4d737
commit 85ccf42cd0

View File

@ -931,8 +931,8 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
ret = -1;
VIR_DEBUG("Result stdout: '%s' stderr: '%s'",
NULLSTR(*cmd->outbuf),
NULLSTR(*cmd->errbuf));
cmd->outbuf ? NULLSTR(*cmd->outbuf) : "(null)",
cmd->errbuf ? NULLSTR(*cmd->errbuf) : "(null)");
/* Reset any capturing, in case caller runs
* this identical command again */