1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-11-30 04:23:46 +03:00

iothread: fix memory access out of bounds

When the 'pcpu' is larger then the last 'iothr->cpumap' bits,
set the list element to False to avoid out of bounds access
'iothr->cpumap'.

Signed-off-by: suruifeng <suruifeng@huawei.com>
Reviewed-by: Hogan Wang <hogan.wang@huawei.com>
This commit is contained in:
w00506750
2021-04-29 15:58:59 +08:00
committed by Daniel P. Berrangé
parent 23ea62992f
commit b47727460e

View File

@@ -1625,10 +1625,14 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self ATTRIBUTE_UNUSED,
VIR_PY_TUPLE_SET_GOTO(iothrtpl, 1, iothrmap, cleanup);
for (pcpu = 0; pcpu < cpunum; pcpu++)
VIR_PY_LIST_SET_GOTO(iothrmap, pcpu,
PyBool_FromLong(VIR_CPU_USED(iothr->cpumap,
pcpu)),
cleanup);
if (VIR_CPU_MAPLEN(pcpu + 1) > iothr->cpumaplen) {
VIR_PY_LIST_SET_GOTO(iothrmap, pcpu, PyBool_FromLong(0), cleanup);
} else {
VIR_PY_LIST_SET_GOTO(iothrmap, pcpu,
PyBool_FromLong(VIR_CPU_USED(iothr->cpumap,
pcpu)),
cleanup);
}
}
py_retval = py_iothrinfo;