From 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d Mon Sep 17 00:00:00 2001 From: "Alexander E. Patrakov" Date: Mon, 4 Jun 2012 23:59:55 +0600 Subject: [PATCH] btrfs: Fix booting off a btrfs subvolume. The subvolume name in path.data is not NUL-terminated, so don't use strcmp on it. Before this patch, it would accumulate the following (given subvolumes with names "ext2_saved", "home", "gentoo" and "boot"): ext2_saved home_saved gentooaved bootooaved Signed-off-by: Alexander E. Patrakov Signed-off-by: H. Peter Anvin --- core/fs/btrfs/btrfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c index b6a14e3..aeb7614 100644 --- a/core/fs/btrfs/btrfs.c +++ b/core/fs/btrfs/btrfs.c @@ -602,12 +602,15 @@ static void btrfs_get_fs_tree(struct fs_info *fs) do { do { struct btrfs_root_ref *ref; + int pathlen; if (btrfs_comp_keys_type(&search_key, &path.item.key)) break; ref = (struct btrfs_root_ref *)path.data; - if (!strcmp((char*)(ref + 1), SubvolName)) { + pathlen = path.item.size - sizeof(struct btrfs_root_ref); + + if (!strncmp((char*)(ref + 1), SubvolName, pathlen)) { subvol_ok = true; break; } -- 2.7.4