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

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



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 redhat com>
---
 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


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