mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 17:42:03 +02:00
btrfs: send: fix is_current_inode_path() to avoid path resets for common prefixes
In case the current inode's path is a prefix of the given path, the helper is_current_inode_path() will return true, which causes the single caller to reset the current inode's path. While this is not a functional issue, it makes the caller recompute the current inode's path later. It could also become a problem in the future in case get new callers for is_current_inode_path() in more sensitive contexts. Example: the current inode path is "/foo/bar" and the path we compare against is "/foo/bar_xyz". Fix this by returning true only if we have exact matches. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Daniel Vacek <neelx@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
a4cea1272c
commit
bd3dddec1b
|
|
@ -625,9 +625,8 @@ static void fs_path_unreverse(struct fs_path *p)
|
|||
static inline bool is_current_inode_path(const struct send_ctx *sctx,
|
||||
const struct fs_path *path)
|
||||
{
|
||||
const struct fs_path *cur = &sctx->cur_inode_path;
|
||||
|
||||
return (strncmp(path->start, cur->start, fs_path_len(cur)) == 0);
|
||||
/* Paths are always nul terminated. */
|
||||
return (strcmp(path->start, sctx->cur_inode_path.start) == 0);
|
||||
}
|
||||
|
||||
static struct btrfs_path *alloc_path_for_send(void)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user