From: John Ferlan Date: Thu, 11 Jul 2013 14:31:15 +0000 (-0400) Subject: virsh-interface: Resolve Coverity issues X-Git-Tag: CVE-2013-4154~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50210ab9ff9dedb8e957b5f18e2ddb0ced324ac3;p=thirdparty%2Flibvirt.git virsh-interface: Resolve Coverity issues Recent changes uncovered FORWARD_NULL and NEGATIVE_RETURNS problems with the processing of the 'nActiveIfaces' and 'nInactiveIfaces' and their associated allocated arrays in 'vshInterfaceListCollect' due to the possibility of returning -1 in a call and using the return value as a for loop index end condition. --- diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 9fdd36e6e6..0f78551043 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -300,10 +300,10 @@ finished: success = true; cleanup: - for (i = 0; i < nActiveIfaces; i++) + for (i = 0; nActiveIfaces != -1 && i < nActiveIfaces; i++) VIR_FREE(activeNames[i]); - for (i = 0; i < nInactiveIfaces; i++) + for (i = 0; nInactiveIfaces != -1 && i < nInactiveIfaces; i++) VIR_FREE(inactiveNames[i]); VIR_FREE(activeNames);