Menu

#2286 gather: bad alloc and usigned returns in metricVirt

Stability
pending-fixed
5
2011-10-18
2011-10-07
No

Error: SIZEOF_MISMATCH:
/builddir/build/BUILD/sblim-gather-2.2.3/plugin/metricVirt.c:298: suspicious_sizeof: Passing argument "sizeof (ids) /*8*/ * node_statistics.num_active_domains" to function "malloc" and then casting the return value to "int *" is suspicious. Did you intend to use "sizeof(*ids)" instead of "sizeof (ids)" ?

Error: NO_EFFECT:
/builddir/build/BUILD/sblim-gather-2.2.3/plugin/metricVirt.c:306: unsigned_compare: This less-than-zero comparison of an unsigned value is never true. "(node_statistics.num_active_domains = virConnectListDomains(conn, ids_ptr, node_statistics.num_active_domains)) < 0U".
/builddir/build/BUILD/sblim-gather-2.2.3/plugin/metricVirt.c:357: unsigned_compare: This less-than-zero comparison of an unsigned value is never true. "(node_statistics.num_inactive_domains = virConnectListDefinedDomains(conn, defdomlist, node_statistics.num_inactive_domains)) < 0U".

The first error overallocates memory.

The second has the side effect that on -1 return from libvirt API the value tested is converted into an unsigned value and the error code path is never taken.

Discussion

  • Tyrel Datwyler

    Tyrel Datwyler - 2011-10-07

    Fixes allocation size and use of unsigned types assigned possible negative values.

     
  • Tyrel Datwyler

    Tyrel Datwyler - 2011-10-18

    Committed to CVS Head.

     
  • Tyrel Datwyler

    Tyrel Datwyler - 2011-10-18
    • status: open --> pending-fixed
     

Log in to post a comment.