aboutsummaryrefslogtreecommitdiff
path: root/lib/ext2fs/punch.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext2fs/punch.c')
-rw-r--r--lib/ext2fs/punch.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c
index effa1e2d..e2543e1e 100644
--- a/lib/ext2fs/punch.c
+++ b/lib/ext2fs/punch.c
@@ -200,6 +200,10 @@ static errcode_t punch_extent_blocks(ext2_filsys fs, ext2_ino_t ino,
__u32 cluster_freed;
errcode_t retval = 0;
+ if (free_start < fs->super->s_first_data_block ||
+ (free_start + free_count) >= ext2fs_blocks_count(fs->super))
+ return EXT2_ET_BAD_BLOCK_NUM;
+
/* No bigalloc? Just free each block. */
if (EXT2FS_CLUSTER_RATIO(fs) == 1) {
*freed += free_count;