提交 8be21728 编写于 作者: D Daniel P. Berrange

Add bounds checking on virConnectListAllInterfaces RPC call

The return values for the virConnectListAllInterfaces 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>
上级 174f7dd5
...@@ -4256,6 +4256,13 @@ remoteDispatchConnectListAllInterfaces(virNetServerPtr server ATTRIBUTE_UNUSED, ...@@ -4256,6 +4256,13 @@ remoteDispatchConnectListAllInterfaces(virNetServerPtr server ATTRIBUTE_UNUSED,
args->flags)) < 0) args->flags)) < 0)
goto cleanup; goto cleanup;
if (nifaces > REMOTE_INTERFACE_LIST_MAX) {
virReportError(VIR_ERR_RPC,
_("Too many interfaces '%d' for limit '%d'"),
nifaces, REMOTE_INTERFACE_LIST_MAX);
goto cleanup;
}
if (ifaces && nifaces) { if (ifaces && nifaces) {
if (VIR_ALLOC_N(ret->ifaces.ifaces_val, nifaces) < 0) if (VIR_ALLOC_N(ret->ifaces.ifaces_val, nifaces) < 0)
goto cleanup; goto cleanup;
......
...@@ -2909,6 +2909,13 @@ remoteConnectListAllInterfaces(virConnectPtr conn, ...@@ -2909,6 +2909,13 @@ remoteConnectListAllInterfaces(virConnectPtr conn,
(char *) &ret) == -1) (char *) &ret) == -1)
goto done; goto done;
if (ret.ifaces.ifaces_len > REMOTE_INTERFACE_LIST_MAX) {
virReportError(VIR_ERR_RPC,
_("Too many interfaces '%d' for limit '%d'"),
ret.ifaces.ifaces_len, REMOTE_INTERFACE_LIST_MAX);
goto cleanup;
}
if (ifaces) { if (ifaces) {
if (VIR_ALLOC_N(tmp_ifaces, ret.ifaces.ifaces_len + 1) < 0) if (VIR_ALLOC_N(tmp_ifaces, ret.ifaces.ifaces_len + 1) < 0)
goto cleanup; goto cleanup;
......
...@@ -91,11 +91,8 @@ const REMOTE_MIGRATE_COOKIE_MAX = 16384; ...@@ -91,11 +91,8 @@ const REMOTE_MIGRATE_COOKIE_MAX = 16384;
/* Upper limit on lists of networks. */ /* Upper limit on lists of networks. */
const REMOTE_NETWORK_LIST_MAX = 16384; const REMOTE_NETWORK_LIST_MAX = 16384;
/* Upper limit on lists of interface names. */ /* Upper limit on lists of interfaces. */
const REMOTE_INTERFACE_NAME_LIST_MAX = 16384; const REMOTE_INTERFACE_LIST_MAX = 16384;
/* Upper limit on lists of defined interface names. */
const REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX = 16384;
/* Upper limit on lists of storage pools. */ /* Upper limit on lists of storage pools. */
const REMOTE_STORAGE_POOL_LIST_MAX = 4096; const REMOTE_STORAGE_POOL_LIST_MAX = 4096;
...@@ -1478,7 +1475,7 @@ struct remote_connect_list_interfaces_args { ...@@ -1478,7 +1475,7 @@ struct remote_connect_list_interfaces_args {
}; };
struct remote_connect_list_interfaces_ret { struct remote_connect_list_interfaces_ret {
remote_nonnull_string names<REMOTE_INTERFACE_NAME_LIST_MAX>; /* insert@1 */ remote_nonnull_string names<REMOTE_INTERFACE_LIST_MAX>; /* insert@1 */
}; };
struct remote_connect_num_of_defined_interfaces_ret { struct remote_connect_num_of_defined_interfaces_ret {
...@@ -1490,7 +1487,7 @@ struct remote_connect_list_defined_interfaces_args { ...@@ -1490,7 +1487,7 @@ struct remote_connect_list_defined_interfaces_args {
}; };
struct remote_connect_list_defined_interfaces_ret { struct remote_connect_list_defined_interfaces_ret {
remote_nonnull_string names<REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX>; /* insert@1 */ remote_nonnull_string names<REMOTE_INTERFACE_LIST_MAX>; /* insert@1 */
}; };
struct remote_interface_lookup_by_name_args { struct remote_interface_lookup_by_name_args {
...@@ -2701,7 +2698,7 @@ struct remote_connect_list_all_interfaces_args { ...@@ -2701,7 +2698,7 @@ struct remote_connect_list_all_interfaces_args {
}; };
struct remote_connect_list_all_interfaces_ret { struct remote_connect_list_all_interfaces_ret {
remote_nonnull_interface ifaces<>; remote_nonnull_interface ifaces<REMOTE_INTERFACE_LIST_MAX>;
unsigned int ret; unsigned int ret;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册