From 85ccf42cd0a8c956230312d6f69dc56666b99871 Mon Sep 17 00:00:00 2001 From: Osier Yang Date: Mon, 6 Dec 2010 17:41:10 +0800 Subject: [PATCH] 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) --- src/util/command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/command.c b/src/util/command.c index aa43f76019..38d462b19d 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -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 */ -- GitLab