libext2fs: fix block iterator when the callback function modifies an extent

If the callback interator modifies a block in the middle of an extent
during a call to the block iterator, causing the extent to be split,
ext2_block_iterate3() will end up calling the callback function twice
for some number of blocks.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index 0e4ec77..95ad31e 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -453,6 +453,17 @@
 			uninit = 0;
 			if (extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT)
 				uninit = EXT2_EXTENT_SET_BMAP_UNINIT;
+#if 0
+			printf("lblk %llu pblk %llu len %d blockcnt %llu\n",
+			       extent.e_lblk, extent.e_pblk,
+			       extent.e_len, blockcnt);
+#endif
+			if (extent.e_lblk + extent.e_len <= blockcnt)
+				continue;
+			if (extent.e_lblk > blockcnt)
+				blockcnt = extent.e_lblk;
+			j = blockcnt - extent.e_lblk;
+			blk += j;
 			for (blockcnt = extent.e_lblk, j = 0;
 			     j < extent.e_len;
 			     blk++, blockcnt++, j++) {