diff --git a/daemon/remote.c b/daemon/remote.c index 512170bfd2ba33945c1a7f55f40f4de7ee8c29cf..b6501e03ae37e0761d956d7a669c81b6d1182de5 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4197,6 +4197,13 @@ remoteDispatchConnectListAllNetworks(virNetServerPtr server ATTRIBUTE_UNUSED, args->flags)) < 0) goto cleanup; + if (nnets > REMOTE_NETWORK_LIST_MAX) { + virReportError(VIR_ERR_RPC, + _("Too many networks '%d' for limit '%d'"), + nnets, REMOTE_NETWORK_LIST_MAX); + goto cleanup; + } + if (nets && nnets) { if (VIR_ALLOC_N(ret->nets.nets_val, nnets) < 0) goto cleanup; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 542cb3917b9e11a6cd269a2f6d159e6e1cfa34b9..e555704758b410a0fad2c47600da984921e7879f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2843,6 +2843,13 @@ remoteConnectListAllNetworks(virConnectPtr conn, (char *) &ret) == -1) goto done; + if (ret.nets.nets_len > REMOTE_NETWORK_LIST_MAX) { + virReportError(VIR_ERR_RPC, + _("Too many networks '%d' for limit '%d'"), + ret.nets.nets_len, REMOTE_NETWORK_LIST_MAX); + goto cleanup; + } + if (nets) { if (VIR_ALLOC_N(tmp_nets, ret.nets.nets_len + 1) < 0) goto cleanup; diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 2034aa1176090a700751c29dbb03c8e55affccc8..f1e27fad0ae473fd05a070af0ffd8fa5de8fc2c9 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -88,8 +88,8 @@ const REMOTE_CPUMAPS_MAX = 8388608; /* Upper limit on migrate cookie. */ const REMOTE_MIGRATE_COOKIE_MAX = 16384; -/* Upper limit on lists of network names. */ -const REMOTE_NETWORK_NAME_LIST_MAX = 16384; +/* Upper limit on lists of networks. */ +const REMOTE_NETWORK_LIST_MAX = 16384; /* Upper limit on lists of interface names. */ const REMOTE_INTERFACE_NAME_LIST_MAX = 16384; @@ -1317,7 +1317,7 @@ struct remote_connect_list_networks_args { }; struct remote_connect_list_networks_ret { - remote_nonnull_string names; /* insert@1 */ + remote_nonnull_string names; /* insert@1 */ }; struct remote_connect_num_of_defined_networks_ret { @@ -1329,7 +1329,7 @@ struct remote_connect_list_defined_networks_args { }; struct remote_connect_list_defined_networks_ret { - remote_nonnull_string names; /* insert@1 */ + remote_nonnull_string names; /* insert@1 */ }; struct remote_network_lookup_by_uuid_args { @@ -2691,7 +2691,7 @@ struct remote_connect_list_all_networks_args { }; struct remote_connect_list_all_networks_ret { - remote_nonnull_network nets<>; + remote_nonnull_network nets; unsigned int ret; };