Blob Blame History Raw
From 1dea4a6a88ede59814c672a907dd24d0a683c2a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Mon, 6 Aug 2018 16:57:47 +0100
Subject: [PATCH] Add missing initialization of virTypedParameters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

For any API call where the API impl allocates the virTypedParameters
array must be passed a NULL-initialized pointer.

Several APIs missed initialization which caused memory corruption.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 62edc0530fe04b4fc81473a5f5d750ae4d54ba3d)
---
 lib/Sys/Virt.xs | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/Sys/Virt.xs b/lib/Sys/Virt.xs
index 40134d3..a013915 100644
--- a/lib/Sys/Virt.xs
+++ b/lib/Sys/Virt.xs
@@ -2403,8 +2403,8 @@ get_node_sev_info(conn, flags=0)
       virConnectPtr conn;
       unsigned int flags;
   PREINIT:
-      virTypedParameterPtr params;
-      int nparams;
+      virTypedParameterPtr params = NULL;
+      int nparams = 0;
     CODE:
       if (virNodeGetSEVInfo(conn, &params, &nparams, flags) < 0) {
           _croak_error();
@@ -4554,8 +4554,8 @@ get_job_stats(dom, flags=0)
       unsigned int flags;
   PREINIT:
       int type;
-      virTypedParameterPtr params;
-      int nparams;
+      virTypedParameterPtr params = NULL;
+      int nparams = 0;
       HV *paramsHv;
       SV *typeSv;
     PPCODE:
@@ -4986,8 +4986,8 @@ get_launch_security_info(dom, flags=0)
       virDomainPtr dom;
       unsigned int flags;
   PREINIT:
-      virTypedParameterPtr params;
-      int nparams;
+      virTypedParameterPtr params = NULL;
+      int nparams = 0;
     CODE:
       if (virDomainGetLaunchSecurityInfo(dom, &params, &nparams, flags) < 0) {
           _croak_error();
@@ -5103,8 +5103,8 @@ get_guest_vcpus(dom, flags=0)
       virDomainPtr dom;
       unsigned int flags;
   PREINIT:
-      virTypedParameterPtr params;
-      unsigned int nparams;
+      virTypedParameterPtr params = NULL;
+      unsigned int nparams = 0;
     CODE:
       if (virDomainGetGuestVcpus(dom, &params, &nparams, flags) < 0) {
           _croak_error();