From c40db6d5717023bdd6bb4935161e7ce9678d6234 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 25 Oct 1999 21:03:34 +0000 Subject: [PATCH] ChangeLog, pass2.c, problem.c, problem.h: problem.c, problem.h (PR_2_NULL_NAME): Add new problem code. pass2.c (check_dir_block): Require that the length of the directory entry be at least 12 bytes. Check to see if the filename is zero-length, and flag that as an error. --- e2fsck/ChangeLog | 8 ++++++++ e2fsck/pass2.c | 8 +++++++- e2fsck/problem.c | 5 +++++ e2fsck/problem.h | 3 +++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index d4f4dc0c..39f35c2e 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,11 @@ +1999-10-25 + + * problem.c, problem.h (PR_2_NULL_NAME): Add new problem code. + + * pass2.c (check_dir_block): Require that the length of the + directory entry be at least 12 bytes. Check to see if the + filename is zero-length, and flag that as an error. + 1999-10-22 * Release of E2fsprogs 1.16 diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index f41cdfef..e6a434cb 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -406,7 +406,7 @@ static int check_dir_block(ext2_filsys fs, cd->pctx.dirent = dirent; cd->pctx.num = offset; if (((offset + dirent->rec_len) > fs->blocksize) || - (dirent->rec_len < 8) || + (dirent->rec_len < 12) || ((dirent->rec_len % 4) != 0) || (((dirent->name_len & 0xFF)+8) > dirent->rec_len)) { if (fix_problem(ctx, PR_2_DIR_CORRUPTED, &cd->pctx)) { @@ -496,6 +496,12 @@ static int check_dir_block(ext2_filsys fs, * directory hasn't been created yet. */ problem = PR_2_LINK_ROOT; + } else if ((dot_state > 2) && + (dirent->name_len & 0xFF) == 0) { + /* + * Don't allow zero-length directory names. + */ + problem = PR_2_NULL_NAME; } if (problem) { diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 718002fb..1e26d607 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -708,6 +708,11 @@ static const struct e2fsck_problem problem_table[] = { "@E has filetype set\n", PROMPT_CLEAR, PR_PREEN_OK }, + /* Directory filename is null */ + { PR_2_NULL_NAME, + "@E has a zero-length name\n", + PROMPT_CLEAR, 0 }, + /* Pass 3 errors */ /* Pass 3: Checking directory connectivity */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index 80b35bee..f9ce29e2 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -420,6 +420,9 @@ struct problem_context { /* Directory filetype set when it shouldn't be */ #define PR_2_CLEAR_FILETYPE 0x020029 +/* Directory filename can't be zero-length */ +#define PR_2_NULL_NAME 0x020030 + /* * Pass 3 errors */