From: Eric Sandeen Date: Tue, 7 Jul 2009 19:30:32 +0000 (-0500) Subject: libext2fs: reset handle after inserting new extent X-Git-Tag: v1.41.8~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4bd87f22906188b6dba36d4b9ba5fc7acd337699;p=thirdparty%2Fe2fsprogs.git libext2fs: reset handle after inserting new extent Commit 53422e moved the new extent insertion in ext2fs_extent_set_bmap() prior to the modification of the original extent, but the insert function left the handle pointing to the new extent. This left us modifying the -new- extent, instead of the original one, and winding up with a corrupt extent tree something like: BLOCKS: (0-1):588791-588792, (0):588791 We need to move back to the previous extent prior to modification, if we inserted a new one. Signed-off-by: Eric Sandeen Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c index 35b080e57..4a4fd2ccc 100644 --- a/lib/ext2fs/extent.c +++ b/lib/ext2fs/extent.c @@ -1257,6 +1257,10 @@ again: EXT2_EXTENT_INSERT_AFTER, &newextent); if (retval) goto done; + /* Now pointing at inserted extent; move back to prev */ + retval = ext2fs_extent_goto(handle, logical - 1); + if (retval) + goto done; } extent.e_len--; retval = ext2fs_extent_replace(handle, 0, &extent);