]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add bounds checking on virConnectListAllDomains RPC call
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 19 Aug 2013 13:23:31 +0000 (14:23 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 29 Aug 2013 14:36:13 +0000 (15:36 +0100)
The return values for the virConnectListAllDomains 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 e228cbab7903c251cc4618eace1d457dffe214d9..8289cb5d5cc5f1d5d388767edd3bbdc2bc87b4cc 100644 (file)
@@ -1050,6 +1050,13 @@ remoteDispatchConnectListAllDomains(virNetServerPtr server ATTRIBUTE_UNUSED,
                                              args->flags)) < 0)
         goto cleanup;
 
+    if (ndomains > REMOTE_DOMAIN_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many domains '%d' for limit '%d'"),
+                       ndomains, REMOTE_DOMAIN_LIST_MAX);
+        goto cleanup;
+    }
+
     if (doms && ndomains) {
         if (VIR_ALLOC_N(ret->domains.domains_val, ndomains) < 0)
             goto cleanup;
index 14c16f61f23901bdfab7224d6773e1ac4fe32693..cd2b9a98c3991a34627e18703547ca7f29b8ba73 100644 (file)
@@ -1370,10 +1370,10 @@ remoteConnectListDomains(virConnectPtr conn, int *ids, int maxids)
 
     remoteDriverLock(priv);
 
-    if (maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
+    if (maxids > REMOTE_DOMAIN_LIST_MAX) {
         virReportError(VIR_ERR_RPC,
-                       _("too many remote domain IDs: %d > %d"),
-                       maxids, REMOTE_DOMAIN_ID_LIST_MAX);
+                       _("Too many domains '%d' for limit '%d'"),
+                       maxids, REMOTE_DOMAIN_LIST_MAX);
         goto done;
     }
     args.maxids = maxids;
@@ -1386,7 +1386,7 @@ remoteConnectListDomains(virConnectPtr conn, int *ids, int maxids)
 
     if (ret.ids.ids_len > maxids) {
         virReportError(VIR_ERR_RPC,
-                       _("too many remote domain IDs: %d > %d"),
+                       _("Too many domains '%d' for limit '%d'"),
                        ret.ids.ids_len, maxids);
         goto cleanup;
     }
@@ -1433,6 +1433,13 @@ remoteConnectListAllDomains(virConnectPtr conn,
              (char *) &ret) == -1)
         goto done;
 
+    if (ret.domains.domains_len > REMOTE_DOMAIN_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many domains '%d' for limit '%d'"),
+                       ret.domains.domains_len, REMOTE_DOMAIN_LIST_MAX);
+        goto cleanup;
+    }
+
     if (domains) {
         if (VIR_ALLOC_N(doms, ret.domains.domains_len + 1) < 0)
             goto cleanup;
index 9e3918c773b1129f3a477f7ec81ecacc9cf95ea4..718e39830572e0b8b1807bb18740c04cd9648f3b 100644 (file)
@@ -73,13 +73,8 @@ typedef string remote_nonnull_string<REMOTE_STRING_MAX>;
 /* A long string, which may be NULL. */
 typedef remote_nonnull_string *remote_string;
 
-/* This just places an upper limit on the length of lists of
- * domain IDs which may be sent via the protocol.
- */
-const REMOTE_DOMAIN_ID_LIST_MAX = 16384;
-
-/* Upper limit on lists of domain names. */
-const REMOTE_DOMAIN_NAME_LIST_MAX = 16384;
+/* Upper limit on lists of domains. */
+const REMOTE_DOMAIN_LIST_MAX = 16384;
 
 /* Upper limit on cpumap (bytes) passed to virDomainPinVcpu. */
 const REMOTE_CPUMAP_MAX = 2048;
@@ -724,7 +719,7 @@ struct remote_connect_list_domains_args {
 };
 
 struct remote_connect_list_domains_ret {
-    int ids<REMOTE_DOMAIN_ID_LIST_MAX>; /* insert@1 */
+    int ids<REMOTE_DOMAIN_LIST_MAX>; /* insert@1 */
 };
 
 struct remote_connect_num_of_domains_ret {
@@ -990,7 +985,7 @@ struct remote_connect_list_defined_domains_args {
 };
 
 struct remote_connect_list_defined_domains_ret {
-    remote_nonnull_string names<REMOTE_DOMAIN_NAME_LIST_MAX>; /* insert@1 */
+    remote_nonnull_string names<REMOTE_DOMAIN_LIST_MAX>; /* insert@1 */
 };
 
 struct remote_connect_num_of_defined_domains_ret {
@@ -2665,7 +2660,7 @@ struct remote_connect_list_all_domains_args {
 };
 
 struct remote_connect_list_all_domains_ret {
-    remote_nonnull_domain domains<>;
+    remote_nonnull_domain domains<REMOTE_DOMAIN_LIST_MAX>;
     unsigned int ret;
 };