]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add bounds checking on virConnectListAllNetworks RPC call
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 19 Aug 2013 13:37:29 +0000 (14:37 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 29 Aug 2013 14:36:13 +0000 (15:36 +0100)
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@redhat.com>
daemon/remote.c
src/remote/remote_driver.c
src/remote/remote_protocol.x

index 512170bfd2ba33945c1a7f55f40f4de7ee8c29cf..b6501e03ae37e0761d956d7a669c81b6d1182de5 100644 (file)
@@ -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;
index 542cb3917b9e11a6cd269a2f6d159e6e1cfa34b9..e555704758b410a0fad2c47600da984921e7879f 100644 (file)
@@ -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;
index 2034aa1176090a700751c29dbb03c8e55affccc8..f1e27fad0ae473fd05a070af0ffd8fa5de8fc2c9 100644 (file)
@@ -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;
 };