diff mbox series

fstools: block: fix segfault on mount with no target

Message ID 20210504132311.2803968-1-daniel@dd-wrt.com
State Accepted
Delegated to: Daniel Golle
Headers show
Series fstools: block: fix segfault on mount with no target | expand

Commit Message

Daniel Danzberger May 4, 2021, 1:23 p.m. UTC
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>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul Spooren May 5, 2021, 2:36 p.m. UTC | #1
On 5/4/21 3:23 PM, Daniel Danzberger wrote:
> 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 | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block.c b/block.c
> index f094216..c6d93d1 100644
> --- 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
diff mbox series

Patch

diff --git a/block.c b/block.c
index f094216..c6d93d1 100644
--- 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