提交 174f7dd5 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 046acaf3
......@@ -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;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册