From d829e785f218714102f23940e68dc71be20cfbd4 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 9 Jan 2024 12:59:24 +0100 Subject: [PATCH] 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 --- misc-utils/hardlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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++) { -- 2.47.3