mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-07-24 00:58:54 +03:00
don't overrun buffer when converting cpumap
If we pass large(more than cpunum) cpu mask to any libvirt_virDomainPin* function, it could leads to crash. So we have to check tuple size in virPyCpumapConvert and ignore extra tuple members. Since we allocate a zeroed buffer, we don't need to bother with setting the bits to zero. Signed-off-by: Konstantin Neumoin <kneumoin@virtuozzo.com>
This commit is contained in:
committed by
Peter Krempa
parent
a03d782b3e
commit
4a77ad764b
@ -623,7 +623,7 @@ virPyCpumapConvert(int cpunum,
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < tuple_size; i++) {
|
||||
for (i = 0; i < cpunum && i < tuple_size; i++) {
|
||||
PyObject *flag = PyTuple_GetItem(pycpumap, i);
|
||||
bool b;
|
||||
|
||||
@ -634,12 +634,7 @@ virPyCpumapConvert(int cpunum,
|
||||
|
||||
if (b)
|
||||
VIR_USE_CPU(*cpumapptr, i);
|
||||
else
|
||||
VIR_UNUSE_CPU(*cpumapptr, i);
|
||||
}
|
||||
|
||||
for (; i < cpunum; i++)
|
||||
VIR_UNUSE_CPU(*cpumapptr, i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user