Skip to content

Commit

Permalink
Btrfs: copy string correctly in INO_LOOKUP ioctl
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Li Zefan authored and Chris Mason committed Aug 1, 2011
1 parent b783e62 commit 77906a5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1757,11 +1757,10 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
key.objectid = key.offset;
key.offset = (u64)-1;
dirid = key.objectid;

}
if (ptr < name)
goto out;
memcpy(name, ptr, total_len);
memmove(name, ptr, total_len);
name[total_len]='\0';
ret = 0;
out:
Expand Down

0 comments on commit 77906a5

Please sign in to comment.