1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-30 01:15:52 +00:00

Fix e2fsck -fD corruption without dirindex on ext2 or small directories

that have entries that sort before '.'.  From upstream's Git repo.

Approved by: miwi@ (mentor)
This commit is contained in:
Matthias Andree 2010-03-14 10:46:48 +00:00
parent ecfbdfca87
commit 03b879ce63
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=251031

View File

@ -0,0 +1,36 @@
commit 53fbfb2bc3490d0ff317666322dd077c08116e0c
Author: Theodore Ts'o <tytso@mit.edu>
Date: Mon Feb 22 23:51:26 2010 -0500
e2fsck: Fix bug which can cause e2fsck -fD to corrupt non-indexed directories
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>
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