]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: avoid integer overflow
authorEric Blake <eblake@redhat.com>
Wed, 29 Jun 2011 17:58:36 +0000 (11:58 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 30 Jun 2011 17:36:51 +0000 (11:36 -0600)
Detected by Coverity.  info.nrVirtCpu is unsigned short, but if
cpumaplen is int, then the product of the two in vshMalloc risks
unintended sign extension.  cmdVcpuinfo had already solved this
by using size_t cpumaplen.

* tools/virsh.c (cmdVcpuPin): Use correct type.

tools/virsh.c

index e82ddae95c6acb74e37fc56d09d50d0ab079d2f4..f96ee040df4540d71cfec7858fc9cd3a78eddf95 100644 (file)
@@ -3025,7 +3025,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     unsigned char *cpumap = NULL;
     unsigned char *cpumaps = NULL;
-    int cpumaplen;
+    size_t cpumaplen;
     bool bit, lastbit, isInvert;
     int i, cpu, lastcpu, maxcpu, ncpus;
     bool unuse = false;