From 4c6fd9c20a3473db3fe419d613244e26c4a92b7b Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Sat, 14 Dec 2013 19:46:50 -0500 Subject: [PATCH] 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. Signed-off-by: Darrick J. Wong Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/punch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c index ff051f7..37cb62c 100644 --- a/lib/ext2fs/punch.c +++ b/lib/ext2fs/punch.c @@ -363,6 +363,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); -- 1.8.3.1