aboutsummaryrefslogtreecommitdiff
path: root/fs/squashfs/block.c
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2017-06-26 18:21:56 -0700
committerMister Oyster <oysterized@gmail.com>2017-06-28 12:07:23 +0200
commit2cb98cb6de4bd687780d60a8377c6c02e2bc47e7 (patch)
tree3f31c065be149578e50ebf8006b268746b79244d /fs/squashfs/block.c
parentda2fece941d2269e1892dcba1b153807167b32f2 (diff)
ANDROID: squashfs: Fix endianness issue
Code in squashfs_process_blocks was not correctly assigning length. Casting to u16* introduced endianness issues on some architectures. Signed-off-by: Daniel Rosenberg <drosen@google.com> Bug: 35257858 Change-Id: I9efaef4bc531b7469de79cf94738ade2dd6e6a8c
Diffstat (limited to 'fs/squashfs/block.c')
-rw-r--r--fs/squashfs/block.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index a08048d17..14192fbbc 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -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