ext2fs_free_mem(&ctx->invalid_inode_table_flag);
ctx->invalid_inode_table_flag = 0;
}
+ if (ctx->encrypted_dirs) {
+ ext2fs_u32_list_free(ctx->encrypted_dirs);
+ ctx->encrypted_dirs = 0;
+ }
/* Clear statistic counters */
ctx->fs_directory_count = 0;
int ret = 0;
for ( i = 0; i < (dirent->name_len & 0xFF); i++) {
- if (dirent->name[i] == '/' || dirent->name[i] == '\0') {
- if (fixup < 0) {
- fixup = fix_problem(ctx, PR_2_BAD_NAME, pctx);
- }
- if (fixup) {
- dirent->name[i] = '.';
- ret = 1;
- }
- }
+ if (dirent->name[i] != '/' && dirent->name[i] != '\0')
+ continue;
+ if (fixup < 0)
+ fixup = fix_problem(ctx, PR_2_BAD_NAME, pctx);
+ if (fixup == 0)
+ return 0;
+ dirent->name[i] = '.';
+ ret = 1;
}
return ret;
}
+static int encrypted_check_name(e2fsck_t ctx,
+ struct ext2_dir_entry *dirent,
+ struct problem_context *pctx)
+{
+ if ((dirent->name_len & 0xff) < EXT4_CRYPTO_BLOCK_SIZE) {
+ if (fix_problem(ctx, PR_2_BAD_ENCRYPTED_NAME, pctx)) {
+ dirent->inode = 0;
+ return 1;
+ }
+ ext2fs_unmark_valid(ctx->fs);
+ }
+ return 0;
+}
+
/*
* Check the directory filetype (if present)
*/
if (!encrypted && check_name(ctx, dirent, &cd->pctx))
dir_modified++;
+ if (encrypted && (dot_state) > 1 &&
+ encrypted_check_name(ctx, dirent, &cd->pctx)) {
+ dir_modified++;
+ goto next;
+ }
+
if (check_filetype(ctx, dirent, ino, &cd->pctx))
dir_modified++;
N_("i_file_acl_hi @F %N, @s zero.\n"),
PROMPT_CLEAR, PR_PREEN_OK },
+ /* Encrypted directory entry is too short */
+ { PR_2_BAD_ENCRYPTED_NAME,
+ N_("Encrypted @E is too short.\n"),
+ PROMPT_CLEAR, 0 },
+
/* Pass 3 errors */
/* Pass 3: Checking directory connectivity */
/* i_file_acl_hi should be zero */
#define PR_2_I_FILE_ACL_HI_ZERO 0x020048
+/* Encrypted directory entry is too short */
+#define PR_2_BAD_ENCRYPTED_NAME 0x020050
+
/*
* Pass 3 errors
*/
#define EXT4_MAX_KEY_SIZE 64
#define EXT4_KEY_DESCRIPTOR_SIZE 8
+#define EXT4_CRYPTO_BLOCK_SIZE 16
/* Password derivation constants */
#define EXT4_MAX_PASSPHRASE_SIZE 1024
if ((struct)->magic != (code)) return (code)
+#define EXT2FS_SHA256_LENGTH 32
+#define EXT2FS_DIGEST_SIZE EXT2FS_SHA256_LENGTH
+
/*
* For ext2 compression support
*/