[syslinux:master] btrfs: Fix booting off a btrfs subvolume.

syslinux-bot for Alexander E. Patrakov patrakov at gmail.com
Mon Jun 4 13:15:07 PDT 2012


Commit-ID:  269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d
Gitweb:     http://www.syslinux.org/commit/269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d
Author:     Alexander E. Patrakov <patrakov at gmail.com>
AuthorDate: Mon, 4 Jun 2012 23:59:55 +0600
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Mon, 4 Jun 2012 13:11:56 -0700

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 <patrakov at gmail.com>
Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>

---
 core/fs/btrfs/btrfs.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

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;
 				}


More information about the Syslinux-commits mailing list