[PATCH v2 1/2] Add check for params, nparams being a dictionary

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

 



If PyDict_Check fails, we should force an error rather than
blindly continuing on.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 libvirt-override.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libvirt-override.c b/libvirt-override.c
index 0353306..8748101 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7861,6 +7861,11 @@ libvirt_virDomainMigrate3(PyObject *self ATTRIBUTE_UNUSED,
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
     dconn = (virConnectPtr) PyvirConnect_Get(pyobj_dconn);
 
+    if (!PyDict_Check(dict)) {
+        PyErr_Format(PyExc_TypeError, "migration params must be a dictionary");
+        return NULL;
+    }
+
     if (virPyDictToTypedParams(dict, &params, &nparams,
                                virPyDomainMigrate3Params,
                                VIR_N_ELEMENTS(virPyDomainMigrate3Params)) < 0) {
@@ -7894,6 +7899,11 @@ libvirt_virDomainMigrateToURI3(PyObject *self ATTRIBUTE_UNUSED,
 
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 
+    if (!PyDict_Check(dict)) {
+        PyErr_Format(PyExc_TypeError, "migration params must be a dictionary");
+        return NULL;
+    }
+
     if (virPyDictToTypedParams(dict, &params, &nparams,
                                virPyDomainMigrate3Params,
                                VIR_N_ELEMENTS(virPyDomainMigrate3Params)) < 0) {
@@ -8776,6 +8786,9 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_UNUSED,
                                    VIR_N_ELEMENTS(virPyDomainBlockCopyParams)) < 0) {
             return NULL;
         }
+    } else {
+        PyErr_Format(PyExc_TypeError, "block params must be a dictionary");
+        return NULL;
     }
 
     dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
-- 
2.17.2

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