Add bounds checking on virConnectListAllStoragePools RPC call

The return values for the virConnectListAllStoragePools call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange
2013-08-19 14:27:56 +01:00
parent 9e97128ba5
commit c853fa8feb
3 changed files with 19 additions and 5 deletions

View File

@@ -4073,6 +4073,13 @@ remoteDispatchConnectListAllStoragePools(virNetServerPtr server ATTRIBUTE_UNUSED
args->flags)) < 0)
goto cleanup;
if (npools > REMOTE_STORAGE_POOL_LIST_MAX) {
virReportError(VIR_ERR_RPC,
_("Too many storage pools '%d' for limit '%d'"),
npools, REMOTE_STORAGE_POOL_LIST_MAX);
goto cleanup;
}
if (pools && npools) {
if (VIR_ALLOC_N(ret->pools.pools_val, npools) < 0)
goto cleanup;