Signed-off-by: Simon Kobyda <skobyda(a)redhat.com>
On Thu, Jul 12, 2018 at 3:10 PM Simon Kobyda <skobyda(a)redhat.com> wrote:
XML shmem name will not include character '/', and will not
be equal to
strings
"." or "..", as shmem name is used in a path.
https://bugzilla.redhat.com/show_bug.cgi?id=1192400
---
Changes in V2
- Added error reports
- Error situation will happen only if shmem name is equal to
"." or "..", however their occurence in a name compromised
of
more
characters is allowed.
src/conf/domain_conf.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7ab2953d83..6b34c17de4 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,26 @@ virDomainDefValidateInternal(const virDomainDef
*def)
return -1;
}
+ for (i = 0; i < def->nshmems; i++) {
+ if (strchr(def->shmems[i]->name, '/')) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("shmem name cannot include '/'
character"));
+ return -1;
+ }
+
+ if (STREQ(def->shmems[i]->name, ".")) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("shmem name cannot be equal to '.'"));
+ return -1;
+ }
+
+ if (STREQ(def->shmems[i]->name, "..")) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("shmem name cannot be equal to '..'"));
+ return -1;
+ }
+ }
+
if (virDomainDefLifecycleActionValidate(def) < 0)
return -1;
--
2.17.1