summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-06-29 11:58:36 -0600
committerEric Blake <eblake@redhat.com>2011-06-30 11:36:51 -0600
commit6f9432fcaf4c8836c7dc2cc60833a07760d821c4 (patch)
treee5558df1f4cd622f3e6f08d9e7127404076be3c7
parentFix stream procedure number for virDomainMigratePrepareTunnel3 (diff)
downloadlibvirt-6f9432fcaf4c8836c7dc2cc60833a07760d821c4.tar.gz
libvirt-6f9432fcaf4c8836c7dc2cc60833a07760d821c4.tar.bz2
libvirt-6f9432fcaf4c8836c7dc2cc60833a07760d821c4.zip
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.
-rw-r--r--tools/virsh.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/virsh.c b/tools/virsh.c
index e82ddae95..f96ee040d 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;