mirror of https://gitee.com/openkylin/libvirt.git
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: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
9e97128ba5
commit
c853fa8feb
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue