On Mon, 14 Jan 2019 13:30:24 +0000, fdmanana@xxxxxxxxxx wrote:
> From: Filipe Manana <fdmanana@xxxxxxxx>
>
> When attempting to find the mount point of a path we can end up returning
> an incorrect mount point. This happens because we consider a mount point
> valid for the given path even if it matches only partially the patch.
s/patch/path/? "...even if it only partially matches" might be a bit
clearer.
> diff --git a/utils.c b/utils.c
> index 3a4bc92a..6616630b 100644
> --- a/utils.c
> +++ b/utils.c
> @@ -2064,7 +2064,8 @@ int find_mount_root(const char *path, char **mount_root)
>
> while ((ent = getmntent(mnttab))) {
> len = strlen(ent->mnt_dir);
> - if (strncmp(ent->mnt_dir, path, len) == 0) {
> + if (strncmp(ent->mnt_dir, path, len) == 0 &&
> + (path[len] == '/' || path[len] == '\0')) {
Looks good and works for me.
Reviewed-by: David Disseldorp <ddiss@xxxxxxx>