mirror of https://gitee.com/openkylin/libvirt.git
Add bounds checking on virConnectListAllNetworks RPC call
The return values for the virConnectListAllNetworks 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:
parent
046acaf37b
commit
174f7dd5ba
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<REMOTE_NETWORK_NAME_LIST_MAX>; /* insert@1 */
|
||||
remote_nonnull_string names<REMOTE_NETWORK_LIST_MAX>; /* 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<REMOTE_NETWORK_NAME_LIST_MAX>; /* insert@1 */
|
||||
remote_nonnull_string names<REMOTE_NETWORK_LIST_MAX>; /* 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<REMOTE_NETWORK_LIST_MAX>;
|
||||
unsigned int ret;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue