[libvirt] [PATCH] conf: virDomainDefValidateInternal prohibit some characters in shmem name

Simon Kobyda skobyda at redhat.com
Tue Jul 10 11:37:34 UTC 2018


XML shmem name will not include characters '/', '.' or '..', as shmem name
is used in a path
https://bugzilla.redhat.com/show_bug.cgi?id=1192400
---
 src/conf/domain_conf.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7ab2953d83..3f580525bb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6107,6 +6107,8 @@ virDomainDefLifecycleActionValidate(const virDomainDef *def)
 static int
 virDomainDefValidateInternal(const virDomainDef *def)
 {
+    size_t i;
+
     if (virDomainDefCheckDuplicateDiskInfo(def) < 0)
         return -1;
 
@@ -6136,6 +6138,17 @@ virDomainDefValidateInternal(const virDomainDef *def)
         return -1;
     }
 
+    for (i = 0; i < def->nshmems; i++) {
+        if (strchr(def->shmems[i]->name, '/'))
+            return -1;
+
+        if (strchr(def->shmems[i]->name, '.'))
+            return -1;
+
+        if (strstr(def->shmems[i]->name, ".."))
+            return -1;
+    }
+
     if (virDomainDefLifecycleActionValidate(def) < 0)
         return -1;
 
-- 
2.17.1




More information about the libvir-list mailing list