]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix invalid write in virNumaGetDistances
authorJán Tomko <jtomko@redhat.com>
Mon, 23 Jun 2014 09:49:02 +0000 (11:49 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 23 Jun 2014 12:16:23 +0000 (14:16 +0200)
==== Invalid write of size 4
====    at 0x52E678C: virNumaGetDistances (virnuma.c:479)
====    by 0x5396890: nodeCapsInitNUMA (nodeinfo.c:1796)
====    by 0x203C2B: virQEMUCapsInit (qemu_capabilities.c:960)
====  Address 0xe10a1e0 is 0 bytes after a block of size 0 alloc'd
====    at 0x4C2A6D0: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
====    by 0x52A10D6: virAllocN (viralloc.c:191)
====    by 0x52E674D: virNumaGetDistances (virnuma.c:470)
====    by 0x5396890: nodeCapsInitNUMA (nodeinfo.c:1796)
====    by 0x203C2B: virQEMUCapsInit (qemu_capabilities.c:960)

src/util/virnuma.c

index 90752635cfa410909fe4fe2c2c803e33e2b5ab9a..1745649f9374902a1757139e103bad709352e6a1 100644 (file)
@@ -467,7 +467,7 @@ virNumaGetDistances(int node,
     if ((max_node = virNumaGetMaxNode()) < 0)
         goto cleanup;
 
-    if (VIR_ALLOC_N(*distances, max_node) < 0)
+    if (VIR_ALLOC_N(*distances, max_node + 1) < 0)
         goto cleanup;
 
     *ndistances = max_node + 1;