提交 f90981fe 编写于 作者: J Jan Kara

udf: Add checks to not underflow sector_t

Signed-off-by: NJan Kara <jack@suse.cz>
上级 87bc730c
...@@ -731,13 +731,18 @@ static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock) ...@@ -731,13 +731,18 @@ static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock)
sector_t last[6]; sector_t last[6];
int i; int i;
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
int last_count = 0;
last[0] = lastblock;
last[1] = last[0] - 1; last[last_count++] = lastblock;
last[2] = last[0] + 1; if (lastblock >= 1)
last[3] = last[0] - 2; last[last_count++] = lastblock - 1;
last[4] = last[0] - 150; last[last_count++] = lastblock + 1;
last[5] = last[0] - 152; if (lastblock >= 2)
last[last_count++] = lastblock - 2;
if (lastblock >= 150)
last[last_count++] = lastblock - 150;
if (lastblock >= 152)
last[last_count++] = lastblock - 152;
/* according to spec, anchor is in either: /* according to spec, anchor is in either:
* block 256 * block 256
...@@ -745,7 +750,7 @@ static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock) ...@@ -745,7 +750,7 @@ static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock)
* lastblock * lastblock
* however, if the disc isn't closed, it could be 512 */ * however, if the disc isn't closed, it could be 512 */
for (i = 0; i < ARRAY_SIZE(last); i++) { for (i = 0; i < last_count; i++) {
if (last[i] >= sb->s_bdev->bd_inode->i_size >> if (last[i] >= sb->s_bdev->bd_inode->i_size >>
sb->s_blocksize_bits) sb->s_blocksize_bits)
continue; continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册