Merge "Replace _host suffix with more standard -host suffix." am: f020dde748
am: dc0f76dbd1
* commit 'dc0f76dbd13f758ee7065ec1b7dbc7e6732de9be':
Replace _host suffix with more standard -host suffix.
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index 3693124..1be6b5e 100644
--- a/e2fsck/e2fsck.c
+++ b/e2fsck/e2fsck.c
@@ -139,6 +139,10 @@
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 b606657..16a4da7 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -464,19 +464,32 @@
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 @@
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 2fdc8d2..833115a 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1391,6 +1391,11 @@
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 240326e..aea5abc 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -833,6 +833,9 @@
/* 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 6847b46..fad7118 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -550,6 +550,7 @@
#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 e013fbb..7f3b792 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -536,6 +536,9 @@
if ((struct)->magic != (code)) return (code)
+#define EXT2FS_SHA256_LENGTH 32
+#define EXT2FS_DIGEST_SIZE EXT2FS_SHA256_LENGTH
+
/*
* For ext2 compression support
*/