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: c5dc299aff ("btrfs-progs: prevent incorrect use of subvol_strip_mountpoint")
Signed-off-by: Axel Burri <axel@tty0.ch>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Axel Burri 2018-05-15 17:22:14 +02:00 committed by David Sterba
parent ad6973647e
commit 09827a8a33
1 changed files with 1 additions and 1 deletions

View File

@ -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);
}