fstools: block: fix segfault on mount with no target
authorDaniel Danzberger <daniel@dd-wrt.com>
Tue, 4 May 2021 13:23:11 +0000 (15:23 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Sat, 15 May 2021 23:28:11 +0000 (00:28 +0100)
When a UCI fstab mount config doesn't contain a target option,
a 'block mount' call segfaults when comparing a mount's target (NULL)
to a found mount point returned by find_mount_point()

Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
Acked-by: Paul Spooren <mail@aparcar.org>
block.c

diff --git a/block.c b/block.c
index f094216447391d8fc9be9e28b9e0a2afc0906c54..c6d93d1eb37d125c6efa1aa7e3050641b557ece2 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1021,7 +1021,7 @@ static int mount_device(struct probe_info *pr, int type)
 
        mp = find_mount_point(pr->dev);
        if (mp) {
-               if (m && m->type == TYPE_MOUNT && strcmp(m->target, mp)) {
+               if (m && m->type == TYPE_MOUNT && m->target && strcmp(m->target, mp)) {
                        ULOG_ERR("%s is already mounted on %s\n", pr->dev, mp);
                        err = -1;
                } else