[PATCH 21a/26] snapshot: correctly escape generated xml

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 69278878 fixed one direction of arbitrarily-named snapshots,
but not the round trip path.  While auditing domain_conf, I found
a couple other instances that weren't escaping arbitrary strings.

* src/conf/domain_conf.c (virDomainFSDefFormat)
(virDomainGraphicsListenDefFormat, virDomainSnapshotDefFormat):
Escape arbitrary strings.
---

Noticed this in between 21 and 22.  It could probably be rebased
earlier or later into a series, but I'm sending it as 21a to match
where I tested it.

 src/conf/domain_conf.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d2a9849..7e8da15 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8834,8 +8834,8 @@ virDomainFSDefFormat(virBufferPtr buf,
         }
     }

-    virBufferAsprintf(buf, "      <target dir='%s'/>\n",
-                      def->dst);
+    virBufferEscapeString(buf, "      <target dir='%s'/>\n",
+                          def->dst);

     if (def->readonly)
         virBufferAddLit(buf, "      <readonly/>\n");
@@ -9637,7 +9637,7 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,

     if (def->network &&
         (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)) {
-        virBufferAsprintf(buf, " network='%s'", def->network);
+        virBufferEscapeString(buf, " network='%s'", def->network);
     }

     virBufferAddLit(buf, "/>\n");
@@ -11084,15 +11084,15 @@ char *virDomainSnapshotDefFormat(char *domain_uuid,
     flags |= VIR_DOMAIN_XML_INACTIVE;

     virBufferAddLit(&buf, "<domainsnapshot>\n");
-    virBufferAsprintf(&buf, "  <name>%s</name>\n", def->name);
+    virBufferEscapeString(&buf, "  <name>%s</name>\n", def->name);
     if (def->description)
-        virBufferAsprintf(&buf, "  <description>%s</description>\n",
-                          def->description);
+        virBufferEscapeString(&buf, "  <description>%s</description>\n",
+                              def->description);
     virBufferAsprintf(&buf, "  <state>%s</state>\n",
                       virDomainStateTypeToString(def->state));
     if (def->parent) {
         virBufferAddLit(&buf, "  <parent>\n");
-        virBufferAsprintf(&buf, "    <name>%s</name>\n", def->parent);
+        virBufferEscapeString(&buf, "    <name>%s</name>\n", def->parent);
         virBufferAddLit(&buf, "  </parent>\n");
     }
     virBufferAsprintf(&buf, "  <creationTime>%lld</creationTime>\n",
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]