From: Eric Blake Date: Wed, 29 Jun 2011 17:58:36 +0000 (-0600) Subject: virsh: avoid integer overflow X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=6f9432fcaf4c8836c7dc2cc60833a07760d821c4;p=libvirt.git virsh: avoid integer overflow 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. --- diff --git a/tools/virsh.c b/tools/virsh.c index e82ddae95c..f96ee040df 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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;