From 3957dd39c6c2413c4341258d63a913948f99ac6f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 27 Mar 2019 08:59:02 +0100 Subject: [PATCH] block: prevent mount point confusion Do not perform substring matches when identifying mount points to avoid returning wrong entries, e.g. "/dev/mmcblk0p10" when "/dev/mmcblk0p1" was requested. Fixes: FS#2196 Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2196 Signed-off-by: Jo-Philipp Wich --- block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block.c b/block.c index cfc8727..39212d2 100644 --- a/block.c +++ b/block.c @@ -579,7 +579,6 @@ static char* find_mount_point(char *block) { FILE *fp = fopen("/proc/self/mountinfo", "r"); static char line[256]; - int len = strlen(block); char *point = NULL, *pos, *tmp, *cpoint, *devname; struct stat s; int rstat; @@ -643,7 +642,7 @@ static char* find_mount_point(char *block) *pos = '\0'; devname = tmp; - if (!strncmp(block, devname, len)) { + if (!strcmp(block, devname)) { point = strdup(cpoint); break; } -- 2.25.1