]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: use correct sizeof when allocating cpumap
authorJán Tomko <jtomko@redhat.com>
Thu, 29 Nov 2012 10:23:06 +0000 (11:23 +0100)
committerCole Robinson <crobinso@redhat.com>
Sun, 9 Dec 2012 21:53:40 +0000 (16:53 -0500)
Found by coverity:
Error: SIZEOF_MISMATCH (CWE-569):
    libvirt-0.10.2/tools/virsh-domain.c:4754: suspicious_sizeof: Passing
    argument "8UL /* sizeof (cpumap) */" to function
    "_vshCalloc(vshControl *, size_t, size_t, char const *, int)" and
    then casting the return value to "unsigned char *" is suspicious.

Error: SIZEOF_MISMATCH (CWE-569):
    libvirt-0.10.2/tools/virsh-domain.c:4942: suspicious_sizeof: Passing
    argument "8UL /* sizeof (cpumap) */" to function
    "_vshCalloc(vshControl *, size_t, size_t, char const *, int)" and
    then casting the return value to "unsigned char *" is suspicious.
(cherry picked from commit dc04b2a737c8c4240d0d412080ce798b977068a1)

tools/virsh-domain.c

index 123afdead384355363e2ec15f96e72ba24c25ab7..545ebe26b6ae2a9ccafa081b11f3bc64c5718256 100644 (file)
@@ -4739,7 +4739,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
 
     /* Pin mode: pinning specified vcpu to specified physical cpus*/
 
-    cpumap = vshCalloc(ctl, cpumaplen, sizeof(cpumap));
+    cpumap = vshCalloc(ctl, cpumaplen, sizeof(*cpumap));
     /* Parse cpulist */
     cur = cpulist;
     if (*cur == 0) {
@@ -4927,7 +4927,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
 
     /* Pin mode: pinning emulator threads to specified physical cpus*/
 
-    cpumap = vshCalloc(ctl, cpumaplen, sizeof(cpumap));
+    cpumap = vshCalloc(ctl, cpumaplen, sizeof(*cpumap));
     /* Parse cpulist */
     cur = cpulist;
     if (*cur == 0) {