xenstat: Fix buffer over-run with new_domains being negative.
authorKonrad Rzeszutek Wilk <konrad@kernel.org>
Tue, 10 Sep 2013 15:08:30 +0000 (11:08 -0400)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 13 Sep 2013 12:12:29 +0000 (13:12 +0100)
commit1438d36f96e90d1116bebc6b3013634ca21c49c8
tree1ec1163841298b8bfc8bbe8a87c757ab63fc8d6b
parentae763e4224304983a1cde2fbb3d6e0c4d60b2688
xenstat: Fix buffer over-run with new_domains being negative.

Coverity identified this as:
CID 1055740 Out-of-bounds read - "In xenstat_get_node:
Out-of-bounds read from a buffer (CWE-125)"

And sure enough, if xc_domain_getinfolist returns us -1, we will
try to use it later on in the for (i = 0; i < new_domains; ..)
loop.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/xenstat/libxenstat/src/xenstat.c