From 07c7b20d4e44bd4ae431861b47e314fca40773dd Mon Sep 17 00:00:00 2001 From: Cebtenzzre Date: Wed, 15 Sep 2021 14:22:46 -0400 Subject: [PATCH] utils: rm_offset_get_from_fd: Break early if not contiguous Completing the current loop iteration if the current extent is not contiguous with the last means the extent flags and file offset are updated as if the extents *were* contiguous. In general, this causes calling code to skip every second extent! Also remove a redundant write to file_offset_next that is always clobbered after the loop exits. Fixes #527 --- lib/utilities.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/utilities.c b/lib/utilities.c index 896e231f..c9d44c1a 100644 --- a/lib/utilities.c +++ b/lib/utilities.c @@ -1229,15 +1229,11 @@ RmOff rm_offset_get_from_fd(int fd, RmOff file_offset, RmOff *file_offset_next, /* check if subsequent extents are contiguous */ if(fm_ext.fe_physical != expected) { /* current extent is not contiguous with previous, so we can stop */ - done = TRUE; + g_free(fm); + break; } } - if(!done && file_offset_next != NULL) { - /* update logical offset of next fragment */ - *file_offset_next = fm_ext.fe_logical + fm_ext.fe_length; - } - if(fm_ext.fe_flags & FIEMAP_EXTENT_DATA_INLINE) { rm_util_set_nullable_bool(is_inline, TRUE); }