aboutsummaryrefslogtreecommitdiff
path: root/lib/ext2fs/imager.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext2fs/imager.c')
-rw-r--r--lib/ext2fs/imager.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c
index 586227fc..23290a6a 100644
--- a/lib/ext2fs/imager.c
+++ b/lib/ext2fs/imager.c
@@ -80,6 +80,11 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
goto errout;
}
left = fs->inode_blocks_per_group;
+ if ((blk < fs->super->s_first_data_block) ||
+ (blk + left - 1 >= ext2fs_blocks_count(fs->super))) {
+ retval = EXT2_ET_GDESC_BAD_INODE_TABLE;
+ goto errout;
+ }
while (left) {
c = BUF_BLOCKS;
if (c > left)
@@ -272,7 +277,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,
retval = errno;
goto errout;
}
- if (actual != (ssize_t)fs->blocksize * fs->desc_blocks) {
+ if (actual != (ssize_t)(fs->blocksize * fs->desc_blocks)) {
retval = EXT2_ET_SHORT_WRITE;
goto errout;
}
@@ -367,6 +372,8 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
size = sizeof(buf);
if (size > (cnt >> 3))
size = (cnt >> 3);
+ if (size == 0)
+ break;
retval = ext2fs_get_generic_bmap_range(bmap, itr,
size << 3, buf);
@@ -442,6 +449,8 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
size = sizeof(buf);
if (size > (cnt >> 3))
size = (cnt >> 3);
+ if (size == 0)
+ break;
actual = read(fd, buf, size);
if (actual == -1)