summaryrefslogtreecommitdiffstats
path: root/fs/cramfs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-10-30 12:46:25 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-30 12:46:25 -0700
commit9b190ecca11c6ed6e20f35caef5746416d8ee0f0 (patch)
tree357fa589bb8fd8daeb586697b222506bd1c0eefb /fs/cramfs
parent343a9f35409b68b6de66ecd0db90a277aee90ec2 (diff)
parent56ce68bceeefa38e5b3509bf3d39259138e2d76a (diff)
downloadlinux-9b190ecca11c6ed6e20f35caef5746416d8ee0f0.tar.bz2
Merge tag 'cramfs_fixes' of git://git.linaro.org/people/nicolas.pitre/linux
Pull cramfs fixes from Nicolas Pitre: "Make the Cramfs code more robust against filesystem corruptions, plus trivial indentation fixes" * tag 'cramfs_fixes' of git://git.linaro.org/people/nicolas.pitre/linux: Cramfs: trivial whitespace fixes Cramfs: fix abad comparison when wrap-arounds occur
Diffstat (limited to 'fs/cramfs')
-rw-r--r--fs/cramfs/inode.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 0c35e62f108d..9352487bd0fc 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -202,7 +202,8 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
continue;
blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_SHIFT;
blk_offset += offset;
- if (blk_offset + len > BUFFER_SIZE)
+ if (blk_offset > BUFFER_SIZE ||
+ blk_offset + len > BUFFER_SIZE)
continue;
return read_buffers[i] + blk_offset;
}
@@ -872,8 +873,8 @@ static int cramfs_readpage(struct file *file, struct page *page)
if (unlikely(block_start & CRAMFS_BLK_FLAG_DIRECT_PTR)) {
/* See comments on earlier code. */
u32 prev_start = block_start;
- block_start = prev_start & ~CRAMFS_BLK_FLAGS;
- block_start <<= CRAMFS_BLK_DIRECT_PTR_SHIFT;
+ block_start = prev_start & ~CRAMFS_BLK_FLAGS;
+ block_start <<= CRAMFS_BLK_DIRECT_PTR_SHIFT;
if (prev_start & CRAMFS_BLK_FLAG_UNCOMPRESSED) {
block_start += PAGE_SIZE;
} else {