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

Martin Kletzander mkletzan at redhat.com
Tue Oct 25 14:21:53 UTC 2016


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 at virtuozzo.com>
>---
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161025/1458aa12/attachment-0001.sig>


More information about the libvir-list mailing list