linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: Eric Sandeen <sandeen@redhat.com>
Subject: [PATCH 02/25] e2fsprogs: Remove impossible name_len tests.
Date: Fri, 16 Sep 2011 15:49:17 -0500	[thread overview]
Message-ID: <1316206180-6375-3-git-send-email-sandeen@redhat.com> (raw)
In-Reply-To: <1316206180-6375-1-git-send-email-sandeen@redhat.com>

The name_len field in ext2_dir_entry is actually comprised of
the name length in the lower 8 bytes, and the filetype in the
high 8 bytes.  So in places, we mask name_len with 0xFF to
get the actual length.

But once we have masked name_len with 0xFF, there is no point
in testing whether it is greater than EXT2_NAME_LEN, which
is 255 - or 0xFF.  So all of these tests are extraneous.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 debugfs/dump.c   |    3 +--
 debugfs/htree.c  |    3 +--
 debugfs/ls.c     |    3 +--
 e2fsck/message.c |    2 --
 e2fsck/pass2.c   |    6 ------
 5 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/debugfs/dump.c b/debugfs/dump.c
index 4cf0752..ec36eca 100644
--- a/debugfs/dump.c
+++ b/debugfs/dump.c
@@ -300,8 +300,7 @@ static int rdump_dirent(struct ext2_dir_entry *dirent,
 	const char *dumproot = private;
 	struct ext2_inode inode;
 
-	thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN
-		   ? (dirent->name_len & 0xFF) : EXT2_NAME_LEN);
+	thislen = dirent->name_len & 0xFF;
 	strncpy(name, dirent->name, thislen);
 	name[thislen] = 0;
 
diff --git a/debugfs/htree.c b/debugfs/htree.c
index b829e25..de36bd4 100644
--- a/debugfs/htree.c
+++ b/debugfs/htree.c
@@ -81,8 +81,7 @@ static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino,
 				blk);
 			break;
 		}
-		thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN) ?
-			(dirent->name_len & 0xFF) : EXT2_NAME_LEN;
+		thislen = dirent->name_len & 0xFF;
 		strncpy(name, dirent->name, thislen);
 		name[thislen] = '\0';
 		errcode = ext2fs_dirhash(hash_alg, name,
diff --git a/debugfs/ls.c b/debugfs/ls.c
index 8e019d2..e01fd20 100644
--- a/debugfs/ls.c
+++ b/debugfs/ls.c
@@ -60,8 +60,7 @@ static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
 	int			thislen;
 	struct list_dir_struct *ls = (struct list_dir_struct *) private;
 
-	thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN) ?
-		(dirent->name_len & 0xFF) : EXT2_NAME_LEN;
+	thislen = dirent->name_len & 0xFF;
 	strncpy(name, dirent->name, thislen);
 	name[thislen] = '\0';
 	ino = dirent->inode;
diff --git a/e2fsck/message.c b/e2fsck/message.c
index 49b861d..565c3cd 100644
--- a/e2fsck/message.c
+++ b/e2fsck/message.c
@@ -372,8 +372,6 @@ static _INLINE_ void expand_dirent_expression(ext2_filsys fs, char ch,
 		break;
 	case 'n':
 		len = dirent->name_len & 0xFF;
-		if (len > EXT2_NAME_LEN)
-			len = EXT2_NAME_LEN;
 		if ((ext2fs_get_rec_len(fs, dirent, &rec_len) == 0) &&
 		    (len > rec_len))
 			len = rec_len;
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index e57afb9..9c44aa2 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -858,12 +858,6 @@ out_htree:
 			} else
 				goto abort_free_dict;
 		}
-		if ((dirent->name_len & 0xFF) > EXT2_NAME_LEN) {
-			if (fix_problem(ctx, PR_2_FILENAME_LONG, &cd->pctx)) {
-				dirent->name_len = EXT2_NAME_LEN;
-				dir_modified++;
-			}
-		}
 
 		if (dot_state == 0) {
 			if (check_dot(ctx, dirent, ino, &cd->pctx))
-- 
1.7.4.1


  parent reply	other threads:[~2011-09-16 20:49 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-16 20:49 [PATCH 00/25] e2fsprogs: Misc cleanups & fixes Eric Sandeen
2011-09-16 20:49 ` [PATCH 01/25] libext2: Fix EXT2_LIB_SOFTSUPP masking Eric Sandeen
2011-09-16 22:52   ` Ted Ts'o
2011-09-16 20:49 ` Eric Sandeen [this message]
2011-09-16 22:30   ` [PATCH 02/25] e2fsprogs: Remove impossible name_len tests Andreas Dilger
2011-09-16 22:52   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 03/25] fsck: fix -C option parsing Eric Sandeen
2011-09-16 22:52   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 04/25] mke2fs: remove impossible tests for null usage_types Eric Sandeen
2011-09-16 22:52   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 05/25] libext2: move buf variable completely under ifdef Eric Sandeen
2011-09-16 22:53   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 06/25] libext2fs: Potential null ptr deref in undo_err_handler_init Eric Sandeen
2011-09-16 22:53   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 07/25] e2fsck: handle null fs in print_pathname() Eric Sandeen
2011-09-16 22:53   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 08/25] e2fsprogs: annotate intentional fallthroughs in case statements Eric Sandeen
2011-09-16 22:53   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 09/25] uuidd: Add missing break to option case statement Eric Sandeen
2011-09-16 22:54   ` Ted Ts'o
2011-09-17  0:47     ` Eric Sandeen
2011-09-16 20:49 ` [PATCH 10/25] freefrag: fix up getopt " Eric Sandeen
2011-09-16 22:54   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 11/25] libe2p: reach unreachable code Eric Sandeen
2011-09-16 22:54   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 12/25] e2fsck: Don't store old_op from ehandler_operation if we don't restore it Eric Sandeen
2011-09-16 22:55   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 13/25] e2fsprogs: Fix some error cleanup path bugs Eric Sandeen
2011-09-16 22:55   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 14/25] subst: Fix free of uninit pointers Eric Sandeen
2011-09-16 22:56   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 15/25] filefrag: Fix uninitialized "expected" value Eric Sandeen
2011-09-16 22:56   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 16/25] e2fsck: remove extraneous memset Eric Sandeen
2011-09-16 22:56   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 17/25] mke2fs: Do not let -t or -T be specified more than once Eric Sandeen
2011-09-16 22:57   ` Ted Ts'o
2011-09-16 22:57     ` Ted Ts'o
2011-09-17  0:49       ` Eric Sandeen
2011-09-16 20:49 ` [PATCH 18/25] e2initrd_helper: Fix memory leak on error Eric Sandeen
2011-09-16 22:58   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 19/25] libext2: Fix leaks in write_bitmaps on error returns Eric Sandeen
2011-09-16 22:58   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 20/25] test_icount: fclose() before exit Eric Sandeen
2011-09-16 22:58   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 21/25] e2fsck: Fix leaks in error paths Eric Sandeen
2011-09-16 23:41   ` Ted Ts'o
2011-09-17  0:57     ` Eric Sandeen
2011-09-16 20:49 ` [PATCH 22/25] tune2fs: handle inode and/or block bitmap read failures in resize_inode() Eric Sandeen
2011-09-16 23:57   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 23/25] e2fsprogs: Don't try to close an fd which is negative Eric Sandeen
2011-09-16 23:57   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 24/25] e4defrag: Check error return of sysconf() Eric Sandeen
2011-09-16 23:57   ` Ted Ts'o
2011-09-16 20:49 ` [PATCH 25/25] mke2fs: free tdb_dir string if it came from the profile Eric Sandeen
2011-09-16 23:58   ` Ted Ts'o
2011-09-16 21:27 ` [PATCH 00/25] e2fsprogs: Misc cleanups & fixes Eric Sandeen
2011-09-16 22:05   ` Ted Ts'o
2011-09-16 22:27     ` Eric Sandeen
2011-09-16 23:49       ` Ted Ts'o
2011-09-17  0:58         ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316206180-6375-3-git-send-email-sandeen@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).