btrfs-progs: fi du: catch bogus extent lengths

If we get a zero-length from the ioctl for whatever reason, we should
not crash.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-09-07 14:51:17 +02:00
parent 939bc6323b
commit 44af5de2f3

View File

@ -79,7 +79,7 @@ static int add_shared_extent(u64 start, u64 len, struct rb_root *root)
{
struct shared_extent *sh;
BUG_ON(len == 0);
ASSERT(len != 0);
sh = calloc(1, sizeof(*sh));
if (!sh)
@ -326,6 +326,12 @@ static int du_calc_file_space(int fd, struct rb_root *shared_extents,
if (flags & SKIP_FLAGS)
continue;
if (ext_len == 0) {
warning("extent %llu has length 0, skipping",
(unsigned long long)fm_ext[i].fe_physical);
continue;
}
file_total += ext_len;
if (flags & FIEMAP_EXTENT_SHARED) {
file_shared += ext_len;