[python PATCH] Check return value of libvirt_uintUnwrap

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

 



libvirt_virDomainSendKey didn't check whether libvirt_uintUnwrap
succeeded or not.

https://bugzilla.redhat.com/show_bug.cgi?id=1161039
Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---

Providing extra context for easier review...

 libvirt-override.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libvirt-override.c b/libvirt-override.c
index a53b46f..f496c6e 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7119,47 +7119,48 @@ static PyObject *
 libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
                          PyObject *args)
 {
     PyObject *py_retval;
     virDomainPtr domain;
     PyObject *pyobj_domain;
     PyObject *pyobj_list;
     int codeset;
     int holdtime;
     unsigned int flags;
     int ret;
     size_t i;
     unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
     unsigned int nkeycodes;
 
     if (!PyArg_ParseTuple(args, (char *)"OiiOiI:virDomainSendKey",
                           &pyobj_domain, &codeset, &holdtime, &pyobj_list,
                           &nkeycodes, &flags)) {
         DEBUG("%s failed to parse tuple\n", __FUNCTION__);
         return VIR_PY_INT_FAIL;
     }
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 
     if (!PyList_Check(pyobj_list)) {
         return VIR_PY_INT_FAIL;
     }
 
     if (nkeycodes != PyList_Size(pyobj_list) ||
         nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
         return VIR_PY_INT_FAIL;
     }
 
     for (i = 0; i < nkeycodes; i++) {
-        libvirt_uintUnwrap(PyList_GetItem(pyobj_list, i), &(keycodes[i]));
+        if (libvirt_uintUnwrap(PyList_GetItem(pyobj_list, i), &keycodes[i]) < 0)
+            return VIR_PY_INT_FAIL;
     }
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
     ret = virDomainSendKey(domain, codeset, holdtime, keycodes, nkeycodes, flags);
     LIBVIRT_END_ALLOW_THREADS;
 
     DEBUG("virDomainSendKey ret=%d\n", ret);
 
     py_retval = libvirt_intWrap(ret);
     return py_retval;
 }
 
 #if LIBVIR_CHECK_VERSION(1, 0, 3)
-- 
2.1.3

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