]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Fix bug which will cause libvirtd crash
authorOsier Yang <jyang@redhat.com>
Mon, 6 Dec 2010 09:41:10 +0000 (17:41 +0800)
committerEric Blake <eblake@redhat.com>
Mon, 6 Dec 2010 16:34:54 +0000 (09:34 -0700)
"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)

src/util/command.c

index aa43f76019a4729c8cd987ca97b1d23a917b7e84..38d462b19dbfc50426b4368be1e82db04329427f 100644 (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 */