From: Jo-Philipp Wich Date: Wed, 27 Mar 2019 07:59:02 +0000 (+0100) Subject: block: prevent mount point confusion X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3957dd39c6c2413c4341258d63a913948f99ac6f;p=oweals%2Ffstools.git 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 --- 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; }