diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 29988c36c4a9a4aa08058e80c9f7bb0240cbbf3d..397bd66870df25b862aac3bf4660bc474d9f295d 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -533,6 +533,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
VIR_AUTOFREE(char *) port = NULL;
VIR_AUTOFREE(char *) ver = NULL;
VIR_AUTOFREE(xmlNodePtr *) nodeset = NULL;
+ VIR_AUTOFREE(char *) sourcedir = NULL;
relnode = ctxt->node;
ctxt->node = node;
@@ -630,7 +631,9 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
}
- source->dir = virXPathString("string(./dir/@path)", ctxt);
+ sourcedir = virXPathString("string(./dir/@path)", ctxt);
+ if (sourcedir)
+ source->dir = virFileSanitizePath(sourcedir);
/* In gluster, a missing dir defaults to "/" */
if (!source->dir && pool_type == VIR_STORAGE_POOL_GLUSTER &&
VIR_STRDUP(source->dir, "/") < 0)
diff --git a/tests/storagepoolxml2xmlin/pool-netfs-slash.xml b/tests/storagepoolxml2xmlin/pool-netfs-slash.xml
new file mode 100644
index 0000000000000000000000000000000000000000..63f5d401ba2a8efa25fdf6d1b5cf25fa3224c891
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-netfs-slash.xml
@@ -0,0 +1,20 @@
+
+ nfsimages
+ 7641d5a8-af11-f730-a34e-0a7dfcede71f
+ 0
+ 0
+ 0
+
+
+ /mnt
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-netfs-slash.xml b/tests/storagepoolxml2xmlout/pool-netfs-slash.xml
new file mode 100644
index 0000000000000000000000000000000000000000..8a5f2721376565c601a29164ee6e2d5a08e64896
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-netfs-slash.xml
@@ -0,0 +1,20 @@
+
+ nfsimages
+ 7641d5a8-af11-f730-a34e-0a7dfcede71f
+ 0
+ 0
+ 0
+
+
+ /mnt
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index b6f4cb422642fcac2ccd3b8a2f2e20c27e124170..96dd04faec0149161b4aa7c8fe6d368ebcd207c0 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -73,6 +73,7 @@ mymain(void)
DO_TEST("pool-iscsi");
DO_TEST("pool-iscsi-auth");
DO_TEST("pool-netfs");
+ DO_TEST("pool-netfs-slash");
DO_TEST("pool-netfs-auto");
DO_TEST("pool-netfs-protocol-ver");
DO_TEST("pool-netfs-gluster");