Handle cases where the number of fm_mapped_extents is zero by ignoring
the fm_extents array, as zero is a valid value.
Fixes: https://github.com/util-linux/util-linux/issues/2687
Signed-off-by: Karel Zak <kzak@redhat.com>
if (ioctl(bf, FS_IOC_FIEMAP, (unsigned long) bmap) < 0)
goto done;
- if (amap->fm_mapped_extents != bmap->fm_mapped_extents)
+ if (amap->fm_mapped_extents == 0 ||
+ amap->fm_mapped_extents != bmap->fm_mapped_extents)
goto done;
for (i = 0; i < amap->fm_mapped_extents; i++) {