Whamcloud - gitweb
LU-7381 libext2fs: fix block-mapped file punch
authorAndreas Dilger <andreas.dilger@intel.com>
Fri, 13 Nov 2015 10:48:34 +0000 (03:48 -0700)
committerAndreas Dilger <andreas.dilger@intel.com>
Tue, 10 May 2016 05:12:34 +0000 (23:12 -0600)
commiteb022796b7e9e4f59d3daa102024e0337892cfc7
tree9fe499ccf7238a178701be7d7ef64d5564f184e6
parent03828933748fe390a39f0ae3019c3f93191eb1b7
LU-7381 libext2fs: fix block-mapped file punch

If ext2fs_punch() was called with "end = ~0ULL" to indicate truncate
to the end of file it tried to compute "count" for ext2fs_punch_ind()
based on "start" and "end", but incorrectly passed "count = ~0U" even
when "start" was non-zero, causing an overflow in some cases.

The calling convention for ext2fs_punch_ind() was also gratuitously
different from ext2fs_punch() and ext2fs_punch_extent(), passing
"count" instead of "end" as the last parameter.  Fix this by passing
it "end" like the other functions, and handle "count" internally.

Add checks to ext2fs_punch_ind() if "end" is at or beyond the 2^32
indirect block limit so the 32-bit internal variables don't overflow.

e2fsprogs-commit: e158db537754ae1ffb3ec6184051bd1a4226937a
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Change-Id: Ifb8f76c2fbcc9f320dbbe7c1c2c329ce363ebbe5
Reviewed-on: http://review.whamcloud.com/17152
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lib/ext2fs/punch.c