block: reject mount sections with relative targets
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 12 Apr 2015 20:18:15 +0000 (22:18 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 12 Apr 2015 20:18:15 +0000 (22:18 +0200)
Specifying relative target paths leads to undefined results and confuses
users. Explicitely reject relative paths with a warning instead of doing
random stuff.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
block.c

diff --git a/block.c b/block.c
index aecf36669c5c3b38db6d4a4a78c842a13d291371..4c8dda92fefac06d2a515564bb8ed5c4f67536b3 100644 (file)
--- a/block.c
+++ b/block.c
@@ -274,6 +274,13 @@ static int mount_add(struct uci_section *s)
        if (m->target && !strcmp(m->target, "/overlay"))
                m->extroot = m->overlay = 1;
 
+       if (m->target && *m->target != '/') {
+               ULOG_WARN("ignoring mount section %s due to invalid target '%s'\n",
+                         s->e.name, m->target);
+               free(m);
+               return -1;
+       }
+
        if (m->uuid)
                vlist_add(&mounts, &m->node, m->uuid);
        else if (m->label)