diff options
author | Theodore Ts'o <tytso@mit.edu> | 2022-08-08 21:02:51 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2022-08-08 21:02:51 -0400 |
commit | b770b0fe7e2564afd95f2008533c6db435e74456 (patch) | |
tree | 341b07196ab880e0ebbc4eb9e9c99cca04b625e0 /lib | |
parent | 95d4ab9917cf1503b9c56acac98633efe89d48e5 (diff) | |
download | e2fsprogs-b770b0fe7e2564afd95f2008533c6db435e74456.tar.gz |
libext2fs: make sure the bitmap locations are valid when writing bitmaps
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ext2fs/rw_bitmaps.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index 7be4a55a..1fe65f74 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -119,7 +119,7 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) fs->flags |= EXT2_FLAG_DIRTY; blk = ext2fs_block_bitmap_loc(fs, i); - if (blk) { + if (blk && blk < ext2fs_blocks_count(fs->super)) { retval = io_channel_write_blk64(fs->io, blk, 1, block_buf); if (retval) { @@ -151,7 +151,7 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) fs->flags |= EXT2_FLAG_DIRTY; blk = ext2fs_inode_bitmap_loc(fs, i); - if (blk) { + if (blk && blk < ext2fs_blocks_count(fs->super)) { retval = io_channel_write_blk64(fs->io, blk, 1, inode_buf); if (retval) { @@ -204,14 +204,14 @@ static errcode_t mark_uninit_bg_group_blocks(ext2_filsys fs) * Mark block used for the block bitmap */ blk = ext2fs_block_bitmap_loc(fs, i); - if (blk) + if (blk && blk < ext2fs_blocks_count(fs->super)) ext2fs_mark_block_bitmap2(bmap, blk); /* * Mark block used for the inode bitmap */ blk = ext2fs_inode_bitmap_loc(fs, i); - if (blk) + if (blk && blk < ext2fs_blocks_count(fs->super)) ext2fs_mark_block_bitmap2(bmap, blk); } return 0; |