From 09827a8a332fdb1b74f4e103b8b72b0b800b5d72 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Tue, 15 May 2018 17:22:14 +0200 Subject: [PATCH] btrfs-progs: fix regression preventing send -p with subvolumes mounted on "/" Fix subvol_strip_mountpoint for mnt="/" (len=1). In this case, skip check for trailing slash on full_path (leading slash on full_path is already asserted by strncmp). Issue: #122 Pull-request: #138 Fixes: c5dc299aff6b ("btrfs-progs: prevent incorrect use of subvol_strip_mountpoint") Signed-off-by: Axel Burri Signed-off-by: David Sterba --- utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.c b/utils.c index d81d4980..21de09d3 100644 --- a/utils.c +++ b/utils.c @@ -2460,7 +2460,7 @@ const char *subvol_strip_mountpoint(const char *mnt, const char *full_path) if (!len) return full_path; - if ((strncmp(mnt, full_path, len) != 0) || (full_path[len] != '/')) { + if ((strncmp(mnt, full_path, len) != 0) || ((len > 1) && (full_path[len] != '/'))) { error("not on mount point: %s", mnt); exit(1); }