Whamcloud - gitweb
e2fsck: initialize variable before first use in fast commit replay
authorHarshad Shirwadkar <harshadshirwadkar@gmail.com>
Tue, 23 Feb 2021 17:41:56 +0000 (09:41 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 23 Feb 2021 17:58:16 +0000 (12:58 -0500)
Initialize ext2fs_ex variable in ext4_fc_replay_scan() before first
use.  Also make sure ext2fs_decode_extent() completely overwrites the
extent structure passed to it as argument to prevent potential future
bugs for the users of the function.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/journal.c
lib/ext2fs/extent.c

index a67ef74..8e7ba81 100644 (file)
@@ -289,7 +289,7 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh,
        struct ext4_fc_tail *tail;
        __u8 *start, *end;
        struct ext4_fc_head *head;
-       struct ext2fs_extent ext2fs_ex;
+       struct ext2fs_extent ext2fs_ex = {0};
 
        state = &ctx->fc_replay_state;
 
index 9e61103..b324c7b 100644 (file)
@@ -1797,7 +1797,7 @@ errcode_t ext2fs_decode_extent(struct ext2fs_extent *to, void *addr, int len)
                        << 32);
        to->e_lblk = ext2fs_le32_to_cpu(from->ee_block);
        to->e_len = ext2fs_le16_to_cpu(from->ee_len);
-       to->e_flags |= EXT2_EXTENT_FLAGS_LEAF;
+       to->e_flags = EXT2_EXTENT_FLAGS_LEAF;
        if (to->e_len > EXT_INIT_MAX_LEN) {
                to->e_len -= EXT_INIT_MAX_LEN;
                to->e_flags |= EXT2_EXTENT_FLAGS_UNINIT;