[PATCH] storage: add check for invalid volume name

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

 



If volume name is a path, storageVolCreateXML appends that name to
the specified pool path, that will taint other pools. Adding the
volume check is better for sanity.

Signed-off-by: Jincheng Miao <jmiao@xxxxxxxxxx>
---
 src/storage/storage_driver.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 2cb8347..c3b807f 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -49,6 +49,7 @@
 #include "configmake.h"
 #include "virstring.h"
 #include "viraccessapicheck.h"
+#include "dirname.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
@@ -1864,6 +1865,14 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
         goto cleanup;
     }
 
+    /* Make sure the volume name is not a path */
+    if (last_component(newvol->name) != newvol->name) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("storage volume name '%s' is a path"),
+                       newvol->name);
+        goto cleanup;
+    }
+
     /* Is there ever a valid case for this? */
     if (newvol->target.capacity < origvol->target.capacity)
         newvol->target.capacity = origvol->target.capacity;
-- 
1.8.3.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]