Whamcloud - gitweb
e2fsck: fix unaligned accesses to ext4_fc_add_range and fc_raw_inode
[tools/e2fsprogs.git] / e2fsck / pass2.c
index 8b7f84a..e504b30 100644 (file)
@@ -359,7 +359,8 @@ static int dict_de_cf_cmp(const void *cmp_ctx, const void *a, const void *b)
        de_b = (const struct ext2_dir_entry *) b;
        b_len = ext2fs_dirent_name_len(de_b);
 
-       return ext2fs_casefold_cmp(tbl, de_a->name, a_len, de_b->name, b_len);
+       return ext2fs_casefold_cmp(tbl, (unsigned char *) de_a->name, a_len,
+                                  (unsigned char *) de_b->name, b_len);
 }
 
 /*
@@ -1217,6 +1218,9 @@ inline_read_fail:
                        root = (struct ext2_dx_root_info *) (buf + 24);
                        dx_db->type = DX_DIRBLOCK_ROOT;
                        dx_db->flags |= DX_FLAG_FIRST | DX_FLAG_LAST;
+
+                       /* large_dir was set in pass1 if large dirs were found,
+                        * so ext2_dir_htree_level() should now be correct */
                        if ((root->reserved_zero ||
                             root->info_length < 8 ||
                             root->indirect_levels >=
@@ -1857,9 +1861,12 @@ static void deallocate_inode(e2fsck_t ctx, ext2_ino_t ino, char* block_buf)
        if (inode.i_flags & EXT4_INLINE_DATA_FL)
                goto clear_inode;
 
-       if (LINUX_S_ISREG(inode.i_mode) &&
-           ext2fs_needs_large_file_feature(EXT2_I_SIZE(&inode)))
-               ctx->large_files--;
+       if (ext2fs_needs_large_file_feature(EXT2_I_SIZE(&inode))) {
+               if (LINUX_S_ISREG(inode.i_mode))
+                   ctx->large_files--;
+               else if (LINUX_S_ISDIR(inode.i_mode))
+                   ctx->large_dirs--;
+       }
 
        del_block.ctx = ctx;
        del_block.num = 0;
@@ -2019,6 +2026,7 @@ int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
                        not_fixed++;
        }
        if (inode.i_size_high && !ext2fs_has_feature_largedir(fs->super) &&
+           inode.i_blocks < 1ULL << (29 - EXT2_BLOCK_SIZE_BITS(fs->super)) &&
            LINUX_S_ISDIR(inode.i_mode)) {
                if (fix_problem(ctx, PR_2_DIR_SIZE_HIGH_ZERO, &pctx)) {
                        inode.i_size_high = 0;