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

Add bounds checking on virConnectListAllStoragePools RPC call

The return values for the virConnectListAllStoragePools 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>
上级 9e97128b
......@@ -4073,6 +4073,13 @@ remoteDispatchConnectListAllStoragePools(virNetServerPtr server ATTRIBUTE_UNUSED
args->flags)) < 0)
goto cleanup;
if (npools > REMOTE_STORAGE_POOL_LIST_MAX) {
virReportError(VIR_ERR_RPC,
_("Too many storage pools '%d' for limit '%d'"),
npools, REMOTE_STORAGE_POOL_LIST_MAX);
goto cleanup;
}
if (pools && npools) {
if (VIR_ALLOC_N(ret->pools.pools_val, npools) < 0)
goto cleanup;
......
......@@ -3276,6 +3276,13 @@ remoteConnectListAllStoragePools(virConnectPtr conn,
(char *) &ret) == -1)
goto done;
if (ret.pools.pools_len > REMOTE_STORAGE_POOL_LIST_MAX) {
virReportError(VIR_ERR_RPC,
_("Too many storage pools '%d' for limit '%d'"),
ret.pools.pools_len, REMOTE_STORAGE_POOL_LIST_MAX);
goto cleanup;
}
if (pools) {
if (VIR_ALLOC_N(tmp_pools, ret.pools.pools_len + 1) < 0)
goto cleanup;
......
......@@ -97,8 +97,8 @@ const REMOTE_INTERFACE_NAME_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 pool names. */
const REMOTE_STORAGE_POOL_NAME_LIST_MAX = 4096;
/* Upper limit on lists of storage pools. */
const REMOTE_STORAGE_POOL_LIST_MAX = 4096;
/* Upper limit on lists of storage vol names. */
const REMOTE_STORAGE_VOL_NAME_LIST_MAX = 16384;
......@@ -1604,7 +1604,7 @@ struct remote_connect_list_storage_pools_args {
};
struct remote_connect_list_storage_pools_ret {
remote_nonnull_string names<REMOTE_STORAGE_POOL_NAME_LIST_MAX>; /* insert@1 */
remote_nonnull_string names<REMOTE_STORAGE_POOL_LIST_MAX>; /* insert@1 */
};
struct remote_connect_num_of_defined_storage_pools_ret {
......@@ -1616,7 +1616,7 @@ struct remote_connect_list_defined_storage_pools_args {
};
struct remote_connect_list_defined_storage_pools_ret {
remote_nonnull_string names<REMOTE_STORAGE_POOL_NAME_LIST_MAX>; /* insert@1 */
remote_nonnull_string names<REMOTE_STORAGE_POOL_LIST_MAX>; /* insert@1 */
};
struct remote_connect_find_storage_pool_sources_args {
......@@ -2670,7 +2670,7 @@ struct remote_connect_list_all_storage_pools_args {
};
struct remote_connect_list_all_storage_pools_ret {
remote_nonnull_storage_pool pools<>;
remote_nonnull_storage_pool pools<REMOTE_STORAGE_POOL_LIST_MAX>;
unsigned int ret;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册