From: "Daniel P. Berrange" <berrange(a)redhat.com>
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: 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 512170b..b6501e0 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -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;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 542cb39..e555704 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -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;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 2034aa1..f1e27fa 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -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;
};
--
1.8.3.1