aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRitesh Harjani (IBM) <ritesh.list@gmail.com>2022-11-07 17:50:50 +0530
committerTheodore Ts'o <tytso@mit.edu>2023-01-24 15:19:39 -0500
commitb795c06d8a44f42cdffdf5aa9561ff8de20d78cc (patch)
treef3b82cc50fb0e43e661d90af36b585f30fe91884
parent5c22148e2c60638c63b7ad74b8eb65de0d121425 (diff)
downloade2fsprogs-b795c06d8a44f42cdffdf5aa9561ff8de20d78cc.tar.gz
libext2fs: fix ext2fs_compare_generic_bmap logic
Currently this function was not correctly comparing against the right length of the bitmap. Also when we compare bitarray v/s rbtree bitmap the value returned by ext2fs_test_generic_bmap() could be different in these two implementations. Hence only check against boolean value. Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--lib/ext2fs/gen_bitmap64.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index c860c10ed..f7710afd5 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -629,10 +629,14 @@ errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
(bm1->end != bm2->end))
return neq;
- for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
- if (ext2fs_test_generic_bmap(gen_bm1, i) !=
- ext2fs_test_generic_bmap(gen_bm2, i))
+ for (i = bm1->start; i < bm1->end; i++) {
+ int ret1, ret2;
+ ret1 = !!ext2fs_test_generic_bmap(gen_bm1, i);
+ ret2 = !!ext2fs_test_generic_bmap(gen_bm2, i);
+ if (ret1 != ret2) {
return neq;
+ }
+ }
return 0;
}