Squashfs: Fix sanity check patches on big-endian systems
authorPhillip Lougher <phillip@lougher.demon.co.uk>
Sat, 28 May 2011 23:38:46 +0000 (00:38 +0100)
committerPhillip Lougher <phillip@lougher.demon.co.uk>
Sun, 29 May 2011 09:03:09 +0000 (10:03 +0100)
le64 values should be swapped when accessing on
big-endian systems.

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
fs/squashfs/export.c
fs/squashfs/fragment.c
fs/squashfs/id.c
fs/squashfs/super.c

index 730c562..5e1101f 100644 (file)
@@ -147,7 +147,7 @@ __le64 *squashfs_read_inode_lookup_table(struct super_block *sb,
         * table[0] points to the first inode lookup table metadata block,
         * this should be less than lookup_table_start
         */
         * table[0] points to the first inode lookup table metadata block,
         * this should be less than lookup_table_start
         */
-       if (!IS_ERR(table) && table[0] >= lookup_table_start) {
+       if (!IS_ERR(table) && le64_to_cpu(table[0]) >= lookup_table_start) {
                kfree(table);
                return ERR_PTR(-EINVAL);
        }
                kfree(table);
                return ERR_PTR(-EINVAL);
        }
index 1516a64..0ed6edb 100644 (file)
@@ -90,7 +90,7 @@ __le64 *squashfs_read_fragment_index_table(struct super_block *sb,
         * table[0] points to the first fragment table metadata block, this
         * should be less than fragment_table_start
         */
         * table[0] points to the first fragment table metadata block, this
         * should be less than fragment_table_start
         */
-       if (!IS_ERR(table) && table[0] >= fragment_table_start) {
+       if (!IS_ERR(table) && le64_to_cpu(table[0]) >= fragment_table_start) {
                kfree(table);
                return ERR_PTR(-EINVAL);
        }
                kfree(table);
                return ERR_PTR(-EINVAL);
        }
index a70858e..d38ea3d 100644 (file)
@@ -93,7 +93,7 @@ __le64 *squashfs_read_id_index_table(struct super_block *sb,
         * table[0] points to the first id lookup table metadata block, this
         * should be less than id_table_start
         */
         * table[0] points to the first id lookup table metadata block, this
         * should be less than id_table_start
         */
-       if (!IS_ERR(table) && table[0] >= id_table_start) {
+       if (!IS_ERR(table) && le64_to_cpu(table[0]) >= id_table_start) {
                kfree(table);
                return ERR_PTR(-EINVAL);
        }
                kfree(table);
                return ERR_PTR(-EINVAL);
        }
index 6f26abe..7438850 100644 (file)
@@ -245,7 +245,7 @@ allocate_id_index_table:
                msblk->id_table = NULL;
                goto failed_mount;
        }
                msblk->id_table = NULL;
                goto failed_mount;
        }
-       next_table = msblk->id_table[0];
+       next_table = le64_to_cpu(msblk->id_table[0]);
 
        /* Handle inode lookup table */
        lookup_table_start = le64_to_cpu(sblk->lookup_table_start);
 
        /* Handle inode lookup table */
        lookup_table_start = le64_to_cpu(sblk->lookup_table_start);
@@ -261,7 +261,7 @@ allocate_id_index_table:
                msblk->inode_lookup_table = NULL;
                goto failed_mount;
        }
                msblk->inode_lookup_table = NULL;
                goto failed_mount;
        }
-       next_table = msblk->inode_lookup_table[0];
+       next_table = le64_to_cpu(msblk->inode_lookup_table[0]);
 
        sb->s_export_op = &squashfs_export_ops;
 
 
        sb->s_export_op = &squashfs_export_ops;
 
@@ -286,7 +286,7 @@ handle_fragments:
                msblk->fragment_index = NULL;
                goto failed_mount;
        }
                msblk->fragment_index = NULL;
                goto failed_mount;
        }
-       next_table = msblk->fragment_index[0];
+       next_table = le64_to_cpu(msblk->fragment_index[0]);
 
 check_directory_table:
        /* Sanity check directory_table */
 
 check_directory_table:
        /* Sanity check directory_table */