Gitweb: http://git.kernel.org/linus/f90981fed974759b5057c5a04299fe03d9dbf1d2 Commit: f90981fed974759b5057c5a04299fe03d9dbf1d2 Parent: 87bc730c07a0884d14d6af5c9d49f4669c0a0589 Author: Jan Kara <jack@suse.cz> AuthorDate: Wed Dec 3 17:31:39 2008 +0100 Committer: Jan Kara <jack@suse.cz> CommitDate: Thu Apr 2 12:29:52 2009 +0200 udf: Add checks to not underflow sector_t Signed-off-by: Jan Kara <jack@suse.cz> --- fs/udf/super.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index b9dc6ad..3c2d35d 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -731,13 +731,18 @@ static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock) sector_t last[6]; int i; struct udf_sb_info *sbi = UDF_SB(sb); - - last[0] = lastblock; - last[1] = last[0] - 1; - last[2] = last[0] + 1; - last[3] = last[0] - 2; - last[4] = last[0] - 150; - last[5] = last[0] - 152; + int last_count = 0; + + last[last_count++] = lastblock; + if (lastblock >= 1) + last[last_count++] = lastblock - 1; + last[last_count++] = lastblock + 1; + 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: * block 256 @@ -745,7 +750,7 @@ static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock) * lastblock * 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 >> sb->s_blocksize_bits) continue; -- To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
