grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix missing byte order conversion in get_btrfs_fs_prefix function
@ 2015-06-22  8:45 Michael Chang
  2015-06-26  6:56 ` Andrei Borzenkov
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Chang @ 2015-06-22  8:45 UTC (permalink / raw)
  To: grub-devel

Since btrfs on-disk format uses little-endian, the searched item types
(ROOT_REF, INODE_REF) need converting the byte order in order to
function properly on big-endian systems.
---
 grub-core/osdep/linux/getroot.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
index a2e360f..3978c71 100644
--- a/grub-core/osdep/linux/getroot.c
+++ b/grub-core/osdep/linux/getroot.c
@@ -316,9 +316,9 @@ get_btrfs_fs_prefix (const char *mount_path)
 
 	  tree_id = sargs.buf[2];
 	  br = (struct grub_btrfs_root_backref *) (sargs.buf + 4);
-	  inode_id = br->inode_id;
+	  inode_id = grub_le_to_cpu64 (br->inode_id);
 	  name = br->name;
-	  namelen = br->n;
+	  namelen = grub_le_to_cpu16 (br->n);
 	}
       else
 	{
@@ -345,7 +345,7 @@ get_btrfs_fs_prefix (const char *mount_path)
 
 	  ir = (struct grub_btrfs_inode_ref *) (sargs.buf + 4);
 	  name = ir->name;
-	  namelen = ir->n;
+	  namelen = grub_le_to_cpu16 (ir->n);
 	}
       old = ret;
       ret = xmalloc (namelen + (old ? strlen (old) : 0) + 2);
-- 
1.7.3.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-26  6:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-22  8:45 [PATCH] Fix missing byte order conversion in get_btrfs_fs_prefix function Michael Chang
2015-06-26  6:56 ` Andrei Borzenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).