]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: clamp block-map punch range end to 2^32 blocks
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 15 Dec 2013 00:46:50 +0000 (19:46 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 15 Dec 2013 00:46:53 +0000 (19:46 -0500)
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 <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/punch.c

index ff051f730ff25443709ddf6ddc424f16d5ea38d0..37cb62c2a7a9b834a2eb87190b7ca31d08baeca8 100644 (file)
@@ -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);