]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add bounds checking on virDomain{SnapshotListAllChildren,ListAllSnapshots} RPC calls
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 19 Aug 2013 11:55:53 +0000 (12:55 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 29 Aug 2013 14:36:13 +0000 (15:36 +0100)
The return values for the virDomain{SnapshotListAllChildren,ListAllSnapshots}
calls 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 ad7801193206ae61315f31a948666c23412c7201..e228cbab7903c251cc4618eace1d457dffe214d9 100644 (file)
@@ -3934,6 +3934,13 @@ remoteDispatchDomainListAllSnapshots(virNetServerPtr server ATTRIBUTE_UNUSED,
                                             args->flags)) < 0)
         goto cleanup;
 
+    if (nsnaps > REMOTE_DOMAIN_SNAPSHOT_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many domain snapshots '%d' for limit '%d'"),
+                       nsnaps, REMOTE_DOMAIN_SNAPSHOT_LIST_MAX);
+        goto cleanup;
+    }
+
     if (snaps && nsnaps) {
         if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0)
             goto cleanup;
@@ -3996,6 +4003,13 @@ remoteDispatchDomainSnapshotListAllChildren(virNetServerPtr server ATTRIBUTE_UNU
                                                    args->flags)) < 0)
         goto cleanup;
 
+    if (nsnaps > REMOTE_DOMAIN_SNAPSHOT_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many domain snapshots '%d' for limit '%d'"),
+                       nsnaps, REMOTE_DOMAIN_SNAPSHOT_LIST_MAX);
+        goto cleanup;
+    }
+
     if (snaps && nsnaps) {
         if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0)
             goto cleanup;
index 33b2b0fa7e74737563799b7fc2599c159e72c147..14c16f61f23901bdfab7224d6773e1ac4fe32693 100644 (file)
@@ -5760,6 +5760,14 @@ remoteDomainListAllSnapshots(virDomainPtr dom,
              (char *) &ret) == -1)
         goto done;
 
+    if (ret.snapshots.snapshots_len > REMOTE_DOMAIN_SNAPSHOT_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many domain snapshots '%d' for limit '%d'"),
+                       ret.snapshots.snapshots_len,
+                       REMOTE_DOMAIN_SNAPSHOT_LIST_MAX);
+        goto cleanup;
+    }
+
     if (snapshots) {
         if (VIR_ALLOC_N(snaps, ret.snapshots.snapshots_len + 1) < 0)
             goto cleanup;
@@ -5819,6 +5827,14 @@ remoteDomainSnapshotListAllChildren(virDomainSnapshotPtr parent,
              (char *) &ret) == -1)
         goto done;
 
+    if (ret.snapshots.snapshots_len > REMOTE_DOMAIN_SNAPSHOT_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many domain snapshots '%d' for limit '%d'"),
+                       ret.snapshots.snapshots_len,
+                       REMOTE_DOMAIN_SNAPSHOT_LIST_MAX);
+        goto cleanup;
+    }
+
     if (snapshots) {
         if (VIR_ALLOC_N(snaps, ret.snapshots.snapshots_len + 1) < 0)
             goto cleanup;
index eff7e1c834c8145247cce72c4c0a5ea72d0fb725..9e3918c773b1129f3a477f7ec81ecacc9cf95ea4 100644 (file)
@@ -154,7 +154,7 @@ const REMOTE_AUTH_TYPE_LIST_MAX = 20;
 const REMOTE_DOMAIN_MEMORY_STATS_MAX = 1024;
 
 /* Upper limit on lists of domain snapshots. */
-const REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX = 1024;
+const REMOTE_DOMAIN_SNAPSHOT_LIST_MAX = 1024;
 
 /* Maximum length of a block peek buffer message.
  * Note applications need to be aware of this limit and issue multiple
@@ -2396,7 +2396,7 @@ struct remote_domain_snapshot_list_names_args {
 };
 
 struct remote_domain_snapshot_list_names_ret {
-    remote_nonnull_string names<REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX>; /* insert@1 */
+    remote_nonnull_string names<REMOTE_DOMAIN_SNAPSHOT_LIST_MAX>; /* insert@1 */
 };
 
 struct remote_domain_list_all_snapshots_args {
@@ -2406,7 +2406,7 @@ struct remote_domain_list_all_snapshots_args {
 };
 
 struct remote_domain_list_all_snapshots_ret {
-    remote_nonnull_domain_snapshot snapshots<>;
+    remote_nonnull_domain_snapshot snapshots<REMOTE_DOMAIN_SNAPSHOT_LIST_MAX>;
     int ret;
 };
 
@@ -2426,7 +2426,7 @@ struct remote_domain_snapshot_list_children_names_args {
 };
 
 struct remote_domain_snapshot_list_children_names_ret {
-    remote_nonnull_string names<REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX>; /* insert@1 */
+    remote_nonnull_string names<REMOTE_DOMAIN_SNAPSHOT_LIST_MAX>; /* insert@1 */
 };
 
 struct remote_domain_snapshot_list_all_children_args {
@@ -2436,7 +2436,7 @@ struct remote_domain_snapshot_list_all_children_args {
 };
 
 struct remote_domain_snapshot_list_all_children_ret {
-    remote_nonnull_domain_snapshot snapshots<>;
+    remote_nonnull_domain_snapshot snapshots<REMOTE_DOMAIN_SNAPSHOT_LIST_MAX>;
     int ret;
 };