]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hardlink: fix fiemap use
authorKarel Zak <kzak@redhat.com>
Tue, 9 Jan 2024 11:59:24 +0000 (12:59 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 9 Jan 2024 11:59:24 +0000 (12:59 +0100)
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>
misc-utils/hardlink.c

index 98c9f8d2912ad8da325d87e1b4e97b97b0d0f8dc..f9d3d09ac6bfa0ef021066a891f5f60b4b5fb5e5 100644 (file)
@@ -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++) {