Skip to content

Commit

Permalink
ANDROID: squashfs: Fix endianness issue
Browse files Browse the repository at this point in the history
Code in squashfs_process_blocks was not correctly assigning
length. Casting to u16* introduced endianness issues on some
architectures.

Signed-off-by: Daniel Rosenberg <[email protected]>
Bug: 35257858
Change-Id: I9efaef4bc531b7469de79cf94738ade2dd6e6a8c
  • Loading branch information
drosen-google committed Jun 28, 2017
1 parent 575a44c commit 1675939
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fs/squashfs/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ static void squashfs_process_blocks(struct squashfs_read_request *req)

if (req->data_processing == SQUASHFS_METADATA) {
/* Extract the length of the metadata block */
if (req->offset != msblk->devblksize - 1)
length = *((u16 *)(bh[0]->b_data + req->offset));
else {
length = bh[0]->b_data[req->offset];
length |= bh[1]->b_data[0] << 8;
if (req->offset != msblk->devblksize - 1) {
length = le16_to_cpup((__le16 *)
(bh[0]->b_data + req->offset));
} else {
length = (unsigned char)bh[0]->b_data[req->offset];
length |= (unsigned char)bh[1]->b_data[0] << 8;
}
req->compressed = SQUASHFS_COMPRESSED(length);
req->data_processing = req->compressed ? SQUASHFS_DECOMPRESS
Expand Down

0 comments on commit 1675939

Please sign in to comment.