]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add bounds checking on virStoragePoolListAllVolumes RPC call
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 19 Aug 2013 13:33:58 +0000 (14:33 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 29 Aug 2013 14:36:13 +0000 (15:36 +0100)
The return values for the virStoragePoolListAllVolumes 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 42c1c47fd4a3f31714b3e37113187c2464cde925..512170bfd2ba33945c1a7f55f40f4de7ee8c29cf 100644 (file)
@@ -4136,6 +4136,13 @@ remoteDispatchStoragePoolListAllVolumes(virNetServerPtr server ATTRIBUTE_UNUSED,
                                               args->flags)) < 0)
         goto cleanup;
 
+    if (nvols > REMOTE_STORAGE_VOL_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many storage volumes '%d' for limit '%d'"),
+                       nvols, REMOTE_STORAGE_VOL_LIST_MAX);
+        goto cleanup;
+    }
+
     if (vols && nvols) {
         if (VIR_ALLOC_N(ret->vols.vols_val, nvols) < 0)
             goto cleanup;
index 622647bcc212f25b70ba22b844e5c41e538527a4..542cb3917b9e11a6cd269a2f6d159e6e1cfa34b9 100644 (file)
@@ -3343,6 +3343,13 @@ remoteStoragePoolListAllVolumes(virStoragePoolPtr pool,
              (char *) &ret) == -1)
         goto done;
 
+    if (ret.vols.vols_len > REMOTE_STORAGE_VOL_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many storage volumes '%d' for limit '%d'"),
+                       ret.vols.vols_len, REMOTE_STORAGE_VOL_LIST_MAX);
+        goto cleanup;
+    }
+
     if (vols) {
         if (VIR_ALLOC_N(tmp_vols, ret.vols.vols_len + 1) < 0)
             goto cleanup;
index 6e996b4eff5e48095659097f27f22a022d8d6195..2034aa1176090a700751c29dbb03c8e55affccc8 100644 (file)
@@ -100,8 +100,8 @@ const REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX = 16384;
 /* 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;
+/* Upper limit on lists of storage vols. */
+const REMOTE_STORAGE_VOL_LIST_MAX = 16384;
 
 /* Upper limit on lists of node device names. */
 const REMOTE_NODE_DEVICE_NAME_LIST_MAX = 16384;
@@ -1746,7 +1746,7 @@ struct remote_storage_pool_list_volumes_args {
 };
 
 struct remote_storage_pool_list_volumes_ret {
-    remote_nonnull_string names<REMOTE_STORAGE_VOL_NAME_LIST_MAX>; /* insert@1 */
+    remote_nonnull_string names<REMOTE_STORAGE_VOL_LIST_MAX>; /* insert@1 */
 };
 
 
@@ -2681,7 +2681,7 @@ struct remote_storage_pool_list_all_volumes_args {
 };
 
 struct remote_storage_pool_list_all_volumes_ret {
-    remote_nonnull_storage_vol vols<>;
+    remote_nonnull_storage_vol vols<REMOTE_STORAGE_VOL_LIST_MAX>;
     unsigned int ret;
 };