[PATCH 02/12] qemuDomainGetGuestInfo: Validate supported information types

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

 



'qemuDomainGetGuestInfoCheckSupport' despite it's name was not checking
whether the info types are supported. Convert the function to return
integers and include the check.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 241513705d..f9a4cc2758 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -22744,20 +22744,32 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr domain,
     return ret;
 }

-static const unsigned int supportedGuestInfoTypes =
+static const unsigned int qemuDomainGetGuestInfoSupportedTypes =
     VIR_DOMAIN_GUEST_INFO_USERS |
     VIR_DOMAIN_GUEST_INFO_OS |
     VIR_DOMAIN_GUEST_INFO_TIMEZONE |
     VIR_DOMAIN_GUEST_INFO_HOSTNAME |
     VIR_DOMAIN_GUEST_INFO_FILESYSTEM;

-static void
-qemuDomainGetGuestInfoCheckSupport(unsigned int *types)
+static int
+qemuDomainGetGuestInfoCheckSupport(unsigned int types,
+                                   unsigned int *supportedTypes)
 {
-    if (*types == 0)
-        *types = supportedGuestInfoTypes;
+    if (types == 0) {
+        *supportedTypes = qemuDomainGetGuestInfoSupportedTypes;
+        return 0;
+    }
+
+    *supportedTypes = types & qemuDomainGetGuestInfoSupportedTypes;
+
+    if (types != *supportedTypes) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("unsupported guest information types '0x%x'"),
+                       types & ~qemuDomainGetGuestInfoSupportedTypes);
+        return -1;
+    }

-    *types = *types & supportedGuestInfoTypes;
+    return 0;
 }

 static void
@@ -22863,14 +22875,16 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
     int ret = -1;
     int maxparams = 0;
     g_autofree char *hostname = NULL;
-    unsigned int supportedTypes = types;
+    unsigned int supportedTypes;
     int rc;
     size_t nfs = 0;
     qemuAgentFSInfoPtr *agentfsinfo = NULL;
     size_t i;

     virCheckFlags(0, -1);
-    qemuDomainGetGuestInfoCheckSupport(&supportedTypes);
+
+    if (qemuDomainGetGuestInfoCheckSupport(types, &supportedTypes) < 0)
+        return -1;

     if (!(vm = qemuDomainObjFromDomain(dom)))
         goto cleanup;
-- 
2.24.1





[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