linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] e2fsck: Fix bug which can cause e2fsck -fD to corrupt non-indexed directories
@ 2010-02-23  5:43 Theodore Ts'o
  2010-02-24  8:25 ` Andreas Dilger
  0 siblings, 1 reply; 4+ messages in thread
From: Theodore Ts'o @ 2010-02-23  5:43 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

E2fsprogs 1.41.10 introduced a regression (in commit b71e018) where
e2fsck -fD can corrupt non-indexed directories when are exists one or
more file names which alphabetically sort before ".".  This can happen
with ext2 filesystems or for small directories (take less than a
block) which contain filenames that begin with a space or some other
punctuation mark.

Fix this by making sure we never reorder the '.' or '..' entry in the
directory, since they must be first.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 e2fsck/rehash.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index 780742e..ceb8543 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -763,7 +763,12 @@ retry_nohash:
 
 	/* Sort the list */
 resort:
-	qsort(fd.harray, fd.num_array, sizeof(struct hash_entry), hash_cmp);
+	if (fd.compress)
+		qsort(fd.harray+2, fd.num_array-2, sizeof(struct hash_entry),
+		      hash_cmp);
+	else
+		qsort(fd.harray, fd.num_array, sizeof(struct hash_entry),
+		      hash_cmp);
 
 	/*
 	 * Look for duplicates
-- 
1.6.6.1.1.g974db.dirty


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-24 16:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23  5:43 [PATCH] e2fsck: Fix bug which can cause e2fsck -fD to corrupt non-indexed directories Theodore Ts'o
2010-02-24  8:25 ` Andreas Dilger
2010-02-24 15:11   ` tytso
2010-02-24 16:28     ` Eric Sandeen

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).