Add bounds checking on virConnectListAllDomains RPC call

The return values for the virConnectListAllDomains 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 committed 2013-08-29 15:36:13 +01:00
1 parent a43d4f543c
commit 9e97128ba5
3 files changed
+23 -14

No files matched your search

+7
View File
@@ -1050,6 +1050,13 @@ remoteDispatchConnectListAllDomains(virNetServerPtr server ATTRIBUTE_UNUSED,
args->flags)) < 0)
goto cleanup;
if (ndomains > REMOTE_DOMAIN_LIST_MAX) {
virReportError(VIR_ERR_RPC,
_("Too many domains '%d' for limit '%d'"),
ndomains, REMOTE_DOMAIN_LIST_MAX);
goto cleanup;
}
if (doms && ndomains) {
if (VIR_ALLOC_N(ret->domains.domains_val, ndomains) < 0)
goto cleanup;