]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: fix ext2fs_compare_generic_bmap logic
authorRitesh Harjani (IBM) <ritesh.list@gmail.com>
Mon, 7 Nov 2022 12:20:50 +0000 (17:50 +0530)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 24 Jan 2023 20:19:39 +0000 (15:19 -0500)
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>
lib/ext2fs/gen_bitmap64.c

index c860c10ed28f62e7978c2afcacb8f9c58628a269..f7710afd5a218d8b6f3b099b4a97ed7dbaa2e5a7 100644 (file)
@@ -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;
 }