[PATCH v3 5/5] qemu: Escape snapshot name passed to {save, load, del}vm

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

 



---
Version 3:
- new patch

 src/qemu/qemu_monitor_text.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 67e27db..a423212 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2566,13 +2566,15 @@ cleanup:
 
 int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
 {
-    char *cmd;
+    char *cmd = NULL;
     char *reply = NULL;
     int ret = -1;
+    char *safename;
 
-    if (virAsprintf(&cmd, "savevm \"%s\"", name) < 0) {
+    if (!(safename = qemuMonitorEscapeArg(name)) ||
+        virAsprintf(&cmd, "savevm \"%s\"", safename) < 0) {
         virReportOOMError();
-        return -1;
+        goto cleanup;
     }
 
     if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
@@ -2604,6 +2606,7 @@ int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
     ret = 0;
 
 cleanup:
+    VIR_FREE(safename);
     VIR_FREE(cmd);
     VIR_FREE(reply);
     return ret;
@@ -2611,13 +2614,15 @@ cleanup:
 
 int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
 {
-    char *cmd;
+    char *cmd = NULL;
     char *reply = NULL;
     int ret = -1;
+    char *safename;
 
-    if (virAsprintf(&cmd, "loadvm \"%s\"", name) < 0) {
+    if (!(safename = qemuMonitorEscapeArg(name)) ||
+        virAsprintf(&cmd, "loadvm \"%s\"", safename) < 0) {
         virReportOOMError();
-        return -1;
+        goto cleanup;
     }
 
     if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
@@ -2660,6 +2665,7 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
     ret = 0;
 
 cleanup:
+    VIR_FREE(safename);
     VIR_FREE(cmd);
     VIR_FREE(reply);
     return ret;
@@ -2667,13 +2673,15 @@ cleanup:
 
 int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
 {
-    char *cmd;
+    char *cmd = NULL;
     char *reply = NULL;
     int ret = -1;
+    char *safename;
 
-    if (virAsprintf(&cmd, "delvm \"%s\"", name) < 0) {
+    if (!(safename = qemuMonitorEscapeArg(name)) ||
+        virAsprintf(&cmd, "delvm \"%s\"", safename) < 0) {
         virReportOOMError();
-        return -1;
+        goto cleanup;
     }
     if (qemuMonitorHMPCommand(mon, cmd, &reply)) {
         qemuReportError(VIR_ERR_OPERATION_FAILED,
@@ -2700,6 +2708,7 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
     ret = 0;
 
 cleanup:
+    VIR_FREE(safename);
     VIR_FREE(cmd);
     VIR_FREE(reply);
     return ret;
-- 
1.7.4.1

--
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]