]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 7 Jan 2011 16:06:42 +0000 (17:06 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 7 Jan 2011 16:06:42 +0000 (17:06 +0100)
inopos might be unaligned.

ChangeLog
grub-core/fs/xfs.c

index 0362abd51b565a2bd1d30860af2aa5771343b1cd..ca63b0e8538d560897f331cf62f3362aa1791b6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-01-07  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that
+       inopos might be unaligned.
+
 2011-01-07  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing
index 3d773856e3ac63d49e9e2e6f604e26f825f2ff4f..9f8dc28def6ebc5fdbf1aa79e4f0788ca378f554 100644 (file)
@@ -451,18 +451,27 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
        for (i = 0; i < diro->inode.data.dir.dirhead.count; i++)
          {
            grub_uint64_t ino;
-           void *inopos = (((char *) de)
+           grub_uint8_t *inopos = (((grub_uint8_t *) de)
                            + sizeof (struct grub_xfs_dir_entry)
                            + de->len - 1);
            char name[de->len + 1];
 
+           /* inopos might be unaligned.  */
            if (smallino)
-             {
-               ino = grub_be_to_cpu32 (*(grub_uint32_t *) inopos);
-               ino = grub_cpu_to_be64 (ino);
-             }
+             ino = (((grub_uint32_t) inopos[0]) << 24)
+               | (((grub_uint32_t) inopos[1]) << 16)
+               | (((grub_uint32_t) inopos[2]) << 8)
+               | (((grub_uint32_t) inopos[3]) << 0);
            else
-             ino = *(grub_uint64_t *) inopos;
+             ino = (((grub_uint64_t) inopos[0]) << 56)
+               | (((grub_uint64_t) inopos[1]) << 48)
+               | (((grub_uint64_t) inopos[2]) << 40)
+               | (((grub_uint64_t) inopos[3]) << 32)
+               | (((grub_uint64_t) inopos[4]) << 24)
+               | (((grub_uint64_t) inopos[5]) << 16)
+               | (((grub_uint64_t) inopos[6]) << 8)
+               | (((grub_uint64_t) inopos[7]) << 0);
+           ino = grub_cpu_to_be64 (ino);
 
            grub_memcpy (name, de->name, de->len);
            name[de->len] = '\0';