From: "Daniel P. Berrange" <berrange(a)redhat.com>
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(a)redhat.com>
---
daemon/remote.c | 7 +++++++
src/remote/remote_driver.c | 7 +++++++
src/remote/remote_protocol.x | 10 +++++-----
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 8289cb5..42c1c47 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -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;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index cd2b9a9..622647b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -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;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 718e398..6e996b4 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -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;
};
--
1.8.3.1