[PATCH python 1/1] fix crash in libvirt_virDomainPin*

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

 



If we pass large(more than cpunum) cpu mask to any libvirt_virDomainPin*
methods, it could leads to crash. So we have to check tuple size and
ignore extra tuple members.

Signed-off-by: Konstantin Neumoin <kneumoin@xxxxxxxxxxxxx>
---
 libvirt-override.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libvirt-override.c b/libvirt-override.c
index fa3e2ca..83b760b 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -1327,7 +1327,7 @@ libvirt_virDomainPinVcpu(PyObject *self ATTRIBUTE_UNUSED,
     if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
         return PyErr_NoMemory();
 
-    for (i = 0; i < tuple_size; i++) {
+    for (i = 0; i < MIN(cpunum, tuple_size); i++) {
         PyObject *flag = PyTuple_GetItem(pycpumap, i);
         bool b;
 
@@ -1392,7 +1392,7 @@ libvirt_virDomainPinVcpuFlags(PyObject *self ATTRIBUTE_UNUSED,
     if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
         return PyErr_NoMemory();
 
-    for (i = 0; i < tuple_size; i++) {
+    for (i = 0; i < MIN(cpunum, tuple_size); i++) {
         PyObject *flag = PyTuple_GetItem(pycpumap, i);
         bool b;
 
@@ -1532,7 +1532,7 @@ libvirt_virDomainPinEmulator(PyObject *self ATTRIBUTE_UNUSED,
     if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
         return PyErr_NoMemory();
 
-    for (i = 0; i < tuple_size; i++) {
+    for (i = 0; i < MIN(cpunum, tuple_size); i++) {
         PyObject *flag = PyTuple_GetItem(pycpumap, i);
         bool b;
 
@@ -1738,7 +1738,7 @@ libvirt_virDomainPinIOThread(PyObject *self ATTRIBUTE_UNUSED,
     if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
         return PyErr_NoMemory();
 
-    for (i = 0; i < tuple_size; i++) {
+    for (i = 0; i < MIN(cpunum, tuple_size); i++) {
         PyObject *flag = PyTuple_GetItem(pycpumap, i);
         bool b;
 
-- 
2.5.5

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