From: Karel Zak Date: Tue, 9 Jan 2024 11:59:24 +0000 (+0100) Subject: hardlink: fix fiemap use X-Git-Tag: v2.40-rc1~61 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Futil-linux.git;a=commitdiff_plain;h=d829e785f218714102f23940e68dc71be20cfbd4 hardlink: fix fiemap use 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 --- diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c index 98c9f8d291..f9d3d09ac6 100644 --- a/misc-utils/hardlink.c +++ b/misc-utils/hardlink.c @@ -991,7 +991,8 @@ static int is_reflink(struct file *xa, struct file *xb) 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++) {