Whamcloud - gitweb
LU-7381 libext2fs: fix block-mapped file punch 52/17152/5
authorAndreas Dilger <andreas.dilger@intel.com>
Fri, 13 Nov 2015 10:48:34 +0000 (03:48 -0700)
committerAndreas Dilger <andreas.dilger@intel.com>
Wed, 9 Dec 2015 19:52:20 +0000 (19:52 +0000)
commit229a4739bd8d68192c669e13c411d57575cdc632
treee1e9bbce326fa5a0ad7e534168bd25a0a277f425
parent18b6aca349550ca6f2cf65462c575f9b502670cc
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