]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add bounds checking on virConnectListAllInterfaces RPC call
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 19 Aug 2013 13:41:56 +0000 (14:41 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 29 Aug 2013 14:36:13 +0000 (15:36 +0100)
The return values for the virConnectListAllInterfaces 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 b6501e03ae37e0761d956d7a669c81b6d1182de5..871b0df6c7e4666fe5980ef94369308a2bf7ee0f 100644 (file)
@@ -4256,6 +4256,13 @@ remoteDispatchConnectListAllInterfaces(virNetServerPtr server ATTRIBUTE_UNUSED,
                                                args->flags)) < 0)
         goto cleanup;
 
+    if (nifaces > REMOTE_INTERFACE_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many interfaces '%d' for limit '%d'"),
+                       nifaces, REMOTE_INTERFACE_LIST_MAX);
+        goto cleanup;
+    }
+
     if (ifaces && nifaces) {
         if (VIR_ALLOC_N(ret->ifaces.ifaces_val, nifaces) < 0)
             goto cleanup;
index e555704758b410a0fad2c47600da984921e7879f..4d82452583609d581d0a33b6d0c7c29fb0774284 100644 (file)
@@ -2909,6 +2909,13 @@ remoteConnectListAllInterfaces(virConnectPtr conn,
              (char *) &ret) == -1)
         goto done;
 
+    if (ret.ifaces.ifaces_len > REMOTE_INTERFACE_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many interfaces '%d' for limit '%d'"),
+                       ret.ifaces.ifaces_len, REMOTE_INTERFACE_LIST_MAX);
+        goto cleanup;
+    }
+
     if (ifaces) {
         if (VIR_ALLOC_N(tmp_ifaces, ret.ifaces.ifaces_len + 1) < 0)
             goto cleanup;
index f1e27fad0ae473fd05a070af0ffd8fa5de8fc2c9..573d63fc86edd4de82db00fafece4fd12b7022ee 100644 (file)
@@ -91,11 +91,8 @@ const REMOTE_MIGRATE_COOKIE_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;
-
-/* Upper limit on lists of defined interface names. */
-const REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX = 16384;
+/* Upper limit on lists of interfaces. */
+const REMOTE_INTERFACE_LIST_MAX = 16384;
 
 /* Upper limit on lists of storage pools. */
 const REMOTE_STORAGE_POOL_LIST_MAX = 4096;
@@ -1478,7 +1475,7 @@ struct remote_connect_list_interfaces_args {
 };
 
 struct remote_connect_list_interfaces_ret {
-    remote_nonnull_string names<REMOTE_INTERFACE_NAME_LIST_MAX>; /* insert@1 */
+    remote_nonnull_string names<REMOTE_INTERFACE_LIST_MAX>; /* insert@1 */
 };
 
 struct remote_connect_num_of_defined_interfaces_ret {
@@ -1490,7 +1487,7 @@ struct remote_connect_list_defined_interfaces_args {
 };
 
 struct remote_connect_list_defined_interfaces_ret {
-    remote_nonnull_string names<REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX>; /* insert@1 */
+    remote_nonnull_string names<REMOTE_INTERFACE_LIST_MAX>; /* insert@1 */
 };
 
 struct remote_interface_lookup_by_name_args {
@@ -2701,7 +2698,7 @@ struct remote_connect_list_all_interfaces_args {
 };
 
 struct remote_connect_list_all_interfaces_ret {
-    remote_nonnull_interface ifaces<>;
+    remote_nonnull_interface ifaces<REMOTE_INTERFACE_LIST_MAX>;
     unsigned int ret;
 };