libext2fs: clamp block-map punch range end to 2^32 blocks
PATCH 1/1 libext2fs: clamp block-map punch range end to 2^32 blocks
In the ^extent case, passing ~0ULL as the 'end' parameter to ext2fs_punch() causes the (end - start + 1) calculation to overflow to zero. Since the old-style mapped block files cannot have more than 2^32 blocks, just clamp it to ~0U.
This fixes a regression in t_quota_2off with the patch "libext2fs: use ext2fs_punch() to truncate quota file" applied.
--- lib/ext2fs/punch.c | 2 ++ 1 file changed, 2 insertions(+)
lib/ext2fs/punch.c +2 -0
@@ -435,6 +435,8 @@ extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,if (start > ~0U )return 0 ; +if (end > ~0U ) + end = ~0U ; count = ((end - start +1 ) < ~0U ) ? (end - start +1 ) : ~0U ; retval =ext2fs_punch_ind (fs, inode, block_buf, (blk_t ) start, count);
Theodore Ts'o
AppliedQuoted 9 lines · Darrick J. Wong
In the ^extent case, passing ~0ULL as the 'end' parameter to
ext2fs_punch()causes the (end - start + 1) calculation to overflow to zero. Since the old-style mapped block files cannot have more than 2^32 blocks, just clamp it to ~0U.This fixes a regression in
t_quota_2offwith the patch "libext2fs: useext2fs_punch()to truncate quota file" applied.Signed-off-by Darrick J. Wong <[email protected]>
Thanks, applied.
- Ted