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.
This commit is contained in:
Eric Blake 2011-06-29 11:58:36 -06:00
parent 1414cc5fdd
commit 6f9432fcaf

View 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;