[PATCH] qemu: avoid pass null pointer as an argument

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

 



In fact, 'pos' is always -1, this reason is because qemuProcessStart function
assigns -1 to 'pos' variable then call qemuProcessWaitForMonitor, meanwhile,
qemuProcessAttach function also call qemuProcessWaitForMonitor and directly
pass -1 as an argument, so if (pos != -1) statement can't been run for ever,
it also means we can't allocate memory to 'buf' variable, that is, 'buf' is
a initial value NULL, however, the function 
qemuProcessReadLogFD(logfd, buf, buf_size, strlen(buf)) will be called
on 'cleanup' section, null pointer passed as an argument.

* src/qemu/qemu_process.c: avoid null pointer passed as an argument to a
 'nonnull' parameter.

Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 src/qemu/qemu_process.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b0d2149..570992d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1189,6 +1189,11 @@ qemuProcessWaitForMonitor(struct qemud_driver* driver,
             goto closelog;
     }
 
+    if (VIR_ALLOC_N(buf, buf_size) < 0) {
+        virReportOOMError();
+        return -1;
+    }
+
     VIR_DEBUG("Connect monitor to %p '%s'", vm, vm->def->name);
     if (qemuConnectMonitor(driver, vm) < 0) {
         goto cleanup;
-- 
1.7.5.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]