diff options
author | David Sterba <dsterba@suse.com> | 2016-09-07 14:51:17 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-10-03 11:33:04 +0200 |
commit | 44af5de2f381f641f04948dd7e95888652648f39 (patch) | |
tree | 38cffe5310afe6882b2151f900d1907178017612 /cmds-fi-du.c | |
parent | 939bc6323b701e860a4f45148d664c336c9c0afa (diff) |
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>
Diffstat (limited to 'cmds-fi-du.c')
-rw-r--r-- | cmds-fi-du.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cmds-fi-du.c b/cmds-fi-du.c index ec8e550f..47ceb969 100644 --- a/cmds-fi-du.c +++ b/cmds-fi-du.c @@ -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; |