Skip to content

Commit 77906a5

Browse files
Li Zefanchrismason-xx
authored andcommitted
Btrfs: copy string correctly in INO_LOOKUP ioctl
Memory areas [ptr, ptr+total_len] and [name, name+total_len] may overlap, so it's wrong to use memcpy(). Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
1 parent b783e62 commit 77906a5

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎fs/btrfs/ioctl.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,11 +1757,10 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
17571757
key.objectid = key.offset;
17581758
key.offset = (u64)-1;
17591759
dirid = key.objectid;
1760-
17611760
}
17621761
if (ptr < name)
17631762
goto out;
1764-
memcpy(name, ptr, total_len);
1763+
memmove(name, ptr, total_len);
17651764
name[total_len]='\0';
17661765
ret = 0;
17671766
out:

0 commit comments

Comments
 (0)