]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: fix key extension in undo_write_tdb
authorMarcus Huewe <suse-tux@gmx.de>
Thu, 12 May 2016 19:35:44 +0000 (15:35 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 12 May 2016 19:35:44 +0000 (15:35 -0400)
Support key extension if the tdb_data_size is an arbitrary integer
multiple of the channel's block size. Before, key extension was only
possible if the tdb_data_size and the channel's block size were
equal.
Note: a key, whose data is the result of a short read, will be
extended if the tdb_data_size and the channel's block size are equal
(that's what the old code did) (if tdb_data_size is an arbitrary
integer multiple (> 1) of the channel's block size, the key might
be extended as well (depending on the keysize)).

Signed-off-by: Marcus Huewe <suse-tux@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/undo_io.c

index 4cc1e9d339827bb28aed382f154f9f8e4075d096..cb8eaa85dd138650da9e947cf67610524c89c81c 100644 (file)
@@ -417,11 +417,11 @@ static errcode_t undo_write_tdb(io_channel channel,
                        keysz = 0;
                }
                if (key != NULL &&
-                   ext2fs_le64_to_cpu(key->fsblk) +
-                   ((keysz + data->tdb_data_size - 1) /
-                    data->tdb_data_size) == backing_blk_num &&
+                   (ext2fs_le64_to_cpu(key->fsblk) * channel->block_size +
+                    channel->block_size - 1 +
+                    keysz) / channel->block_size == backing_blk_num &&
                    E2UNDO_MAX_EXTENT_BLOCKS * data->tdb_data_size >
-                   keysz + sz) {
+                   keysz + data_size) {
                        blk_crc = ext2fs_le32_to_cpu(key->blk_crc);
                        blk_crc = ext2fs_crc32c_le(blk_crc, read_ptr, data_size);
                        key->blk_crc = ext2fs_cpu_to_le32(blk_crc);