[PATCH 1/3] vircommand: Ensure buffers are NULL-terminated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The memory allocated by VIR_REALLOC_N() is uninitialized,
which means it's not possible to figure out whether any
output was produced at all after the fact.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/util/vircommand.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index d965068369..6e9e56d0c0 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -2057,11 +2057,13 @@ virCommandProcessIO(virCommandPtr cmd)
         outfd = cmd->outfd;
         if (VIR_REALLOC_N(*cmd->outbuf, 1) < 0)
             ret = -1;
+        *cmd->outbuf[0] = '\0';
     }
     if (cmd->errbuf) {
         errfd = cmd->errfd;
         if (VIR_REALLOC_N(*cmd->errbuf, 1) < 0)
             ret = -1;
+        *cmd->errbuf[0] = '\0';
     }
     if (ret == -1)
         goto cleanup;
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux