aboutsummaryrefslogtreecommitdiffstats
path: root/fs/squashfs/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/squashfs/block.c')
-rw-r--r--fs/squashfs/block.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index c837dfc2b3c6..321728f48f2d 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -80,7 +80,7 @@ static struct buffer_head *get_block_length(struct super_block *sb,
80 * generated a larger block - this does occasionally happen with zlib). 80 * generated a larger block - this does occasionally happen with zlib).
81 */ 81 */
82int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, 82int squashfs_read_data(struct super_block *sb, void **buffer, u64 index,
83 int length, u64 *next_index, int srclength) 83 int length, u64 *next_index, int srclength, int pages)
84{ 84{
85 struct squashfs_sb_info *msblk = sb->s_fs_info; 85 struct squashfs_sb_info *msblk = sb->s_fs_info;
86 struct buffer_head **bh; 86 struct buffer_head **bh;
@@ -185,6 +185,14 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index,
185 } 185 }
186 186
187 if (msblk->stream.avail_out == 0) { 187 if (msblk->stream.avail_out == 0) {
188 if (page == pages) {
189 ERROR("zlib_inflate tried to "
190 "decompress too much data, "
191 "expected %d bytes. Zlib "
192 "data probably corrupt\n",
193 srclength);
194 goto release_mutex;
195 }
188 msblk->stream.next_out = buffer[page++]; 196 msblk->stream.next_out = buffer[page++];
189 msblk->stream.avail_out = PAGE_CACHE_SIZE; 197 msblk->stream.avail_out = PAGE_CACHE_SIZE;
190 } 198 }
@@ -268,7 +276,8 @@ block_release:
268 put_bh(bh[k]); 276 put_bh(bh[k]);
269 277
270read_failure: 278read_failure:
271 ERROR("sb_bread failed reading block 0x%llx\n", cur_index); 279 ERROR("squashfs_read_data failed to read block 0x%llx\n",
280 (unsigned long long) index);
272 kfree(bh); 281 kfree(bh);
273 return -EIO; 282 return -EIO;
274} 283}