|
|
b06491 |
From 13ba25fa006ae1af1b3a7507cefc9fb433859803 Mon Sep 17 00:00:00 2001
|
|
|
b06491 |
Message-Id: <13ba25fa006ae1af1b3a7507cefc9fb433859803@dist-git>
|
|
|
b06491 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
b06491 |
Date: Mon, 3 Aug 2015 10:26:26 +0200
|
|
|
b06491 |
Subject: [PATCH] Check return value of PyList_Append
|
|
|
b06491 |
|
|
|
b06491 |
libvirt_virDomainGetSecurityLabelList called PyList_Append without
|
|
|
b06491 |
checking its return value. While looking at it I noticed the function
|
|
|
b06491 |
did not properly check several other return values either so I fixed
|
|
|
b06491 |
them all.
|
|
|
b06491 |
|
|
|
b06491 |
https://bugzilla.redhat.com/show_bug.cgi?id=1249511
|
|
|
b06491 |
|
|
|
b06491 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
b06491 |
(cherry picked from commit 5a6b2c98390a2344c9c3cc10a1c346a4838f0d58)
|
|
|
b06491 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
b06491 |
---
|
|
|
b06491 |
libvirt-override.c | 46 ++++++++++++++++++++++++++++++++++++++--------
|
|
|
b06491 |
1 file changed, 38 insertions(+), 8 deletions(-)
|
|
|
b06491 |
|
|
|
b06491 |
diff --git a/libvirt-override.c b/libvirt-override.c
|
|
|
b06491 |
index 2398228..4dfe332 100644
|
|
|
b06491 |
--- a/libvirt-override.c
|
|
|
b06491 |
+++ b/libvirt-override.c
|
|
|
b06491 |
@@ -3144,32 +3144,62 @@ libvirt_virDomainGetSecurityLabel(PyObject *self ATTRIBUTE_UNUSED, PyObject *arg
|
|
|
b06491 |
|
|
|
b06491 |
#if LIBVIR_CHECK_VERSION(0, 10, 0)
|
|
|
b06491 |
static PyObject *
|
|
|
b06491 |
-libvirt_virDomainGetSecurityLabelList(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
|
|
|
b06491 |
+libvirt_virDomainGetSecurityLabelList(PyObject *self ATTRIBUTE_UNUSED,
|
|
|
b06491 |
+ PyObject *args)
|
|
|
b06491 |
+{
|
|
|
b06491 |
PyObject *py_retval;
|
|
|
b06491 |
int c_retval;
|
|
|
b06491 |
virDomainPtr dom;
|
|
|
b06491 |
PyObject *pyobj_dom;
|
|
|
b06491 |
- virSecurityLabel *labels;
|
|
|
b06491 |
+ virSecurityLabel *labels = NULL;
|
|
|
b06491 |
size_t i;
|
|
|
b06491 |
|
|
|
b06491 |
if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetSecurityLabel", &pyobj_dom))
|
|
|
b06491 |
return NULL;
|
|
|
b06491 |
+
|
|
|
b06491 |
dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
|
|
|
b06491 |
|
|
|
b06491 |
LIBVIRT_BEGIN_ALLOW_THREADS;
|
|
|
b06491 |
c_retval = virDomainGetSecurityLabelList(dom, &labels);
|
|
|
b06491 |
LIBVIRT_END_ALLOW_THREADS;
|
|
|
b06491 |
+
|
|
|
b06491 |
if (c_retval < 0)
|
|
|
b06491 |
return VIR_PY_NONE;
|
|
|
b06491 |
- py_retval = PyList_New(0);
|
|
|
b06491 |
+
|
|
|
b06491 |
+ if (!(py_retval = PyList_New(0)))
|
|
|
b06491 |
+ goto error;
|
|
|
b06491 |
+
|
|
|
b06491 |
for (i = 0 ; i < c_retval ; i++) {
|
|
|
b06491 |
- PyObject *entry = PyList_New(2);
|
|
|
b06491 |
- PyList_SetItem(entry, 0, libvirt_constcharPtrWrap(&labels[i].label[0]));
|
|
|
b06491 |
- PyList_SetItem(entry, 1, libvirt_boolWrap(labels[i].enforcing));
|
|
|
b06491 |
- PyList_Append(py_retval, entry);
|
|
|
b06491 |
+ PyObject *entry;
|
|
|
b06491 |
+ PyObject *value;
|
|
|
b06491 |
+
|
|
|
b06491 |
+ if (!(entry = PyList_New(2)) ||
|
|
|
b06491 |
+ PyList_Append(py_retval, entry) < 0) {
|
|
|
b06491 |
+ Py_XDECREF(entry);
|
|
|
b06491 |
+ goto error;
|
|
|
b06491 |
+ }
|
|
|
b06491 |
+
|
|
|
b06491 |
+ if (!(value = libvirt_constcharPtrWrap(&labels[i].label[0])) ||
|
|
|
b06491 |
+ PyList_SetItem(entry, 0, value) < 0) {
|
|
|
b06491 |
+ Py_XDECREF(value);
|
|
|
b06491 |
+ goto error;
|
|
|
b06491 |
+ }
|
|
|
b06491 |
+
|
|
|
b06491 |
+ if (!(value = libvirt_boolWrap(labels[i].enforcing)) ||
|
|
|
b06491 |
+ PyList_SetItem(entry, 1, value) < 0) {
|
|
|
b06491 |
+ Py_XDECREF(value);
|
|
|
b06491 |
+ goto error;
|
|
|
b06491 |
+ }
|
|
|
b06491 |
}
|
|
|
b06491 |
- free(labels);
|
|
|
b06491 |
+
|
|
|
b06491 |
+ cleanup:
|
|
|
b06491 |
+ VIR_FREE(labels);
|
|
|
b06491 |
return py_retval;
|
|
|
b06491 |
+
|
|
|
b06491 |
+ error:
|
|
|
b06491 |
+ Py_XDECREF(py_retval);
|
|
|
b06491 |
+ py_retval = NULL;
|
|
|
b06491 |
+ goto cleanup;
|
|
|
b06491 |
}
|
|
|
b06491 |
#endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
|
|
|
b06491 |
|
|
|
b06491 |
--
|
|
|
b06491 |
2.5.0
|
|
|
b06491 |
|