Skip to contentSkip to conversation

Btrfs: copy string correctly in BTRFS_IOC_INO_LOOKUP ioctl

PATCH New Li Zefan 1 participant 1 message Jun 20, 2011 Btrfs file system

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/1 Btrfs: copy string correctly in BTRFS_IOC_INO_LOOKUP ioctl

Memory areas [ptr, ptr+total_len] and [name, name+total_len] may overlap, so it's wrong to use memcpy().

---
 fs/btrfs/ioctl.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/btrfs/ioctl.c +1 -2
index b793d11..76f52b3 100644
@@ -1753,11 +1753,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:

-- 1.7.3.1