On Tue, Oct 25, 2016 at 12:42:23PM +0300, Konstantin Neumoin wrote:
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++) {
I don't like it being called every single iteration of the loop. Temporary variable outside the loop would be nicer. Also since all these functions do the same thing, why not make a function for this and call it from all the places? It would also make a nice clean-up. Martin
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list