diff options
-rw-r--r-- | e2fsck/e2fsck.c | 4 | ||||
-rw-r--r-- | e2fsck/pass2.c | 37 | ||||
-rw-r--r-- | e2fsck/problem.c | 5 | ||||
-rw-r--r-- | e2fsck/problem.h | 3 | ||||
-rw-r--r-- | lib/ext2fs/ext2_fs.h | 1 | ||||
-rw-r--r-- | lib/ext2fs/ext2fs.h | 3 |
6 files changed, 44 insertions, 9 deletions
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index 36931244..1be6b5e1 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -139,6 +139,10 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx) 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; diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index b6066573..16a4da72 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -464,19 +464,32 @@ static int check_name(e2fsck_t ctx, 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) */ @@ -1041,6 +1054,12 @@ out_htree: 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++; diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 2fdc8d22..833115a7 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -1391,6 +1391,11 @@ static struct e2fsck_problem problem_table[] = { 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 */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index 240326e5..aea5abc5 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -833,6 +833,9 @@ struct problem_context { /* 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 */ diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 6847b46a..fad71181 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -550,6 +550,7 @@ struct ext2_inode_large { #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 diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index e013fbb7..7f3b7926 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -536,6 +536,9 @@ typedef struct ext2_icount *ext2_icount_t; if ((struct)->magic != (code)) return (code) +#define EXT2FS_SHA256_LENGTH 32 +#define EXT2FS_DIGEST_SIZE EXT2FS_SHA256_LENGTH + /* * For ext2 compression support */ |