Whamcloud - gitweb
e2fsck: make insert_dirent_tail more robust
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 27 Jul 2014 23:46:15 +0000 (19:46 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 27 Jul 2014 23:46:15 +0000 (19:46 -0400)
commitd3eb1502fd07a4c751d20ad5fa4b75bfda039d52
tree5e55c5120f2c891b339196af0374151f159516b2
parent82ad476d4709faf9f39a9aa581f9679e8181bbea
e2fsck: make insert_dirent_tail more robust

Fix the routine that adds dirent checksum structures to the directory
block to handle oddball situations a bit more robustly.

First, when we're walking the entry array, we might encounter an
entry that ends exactly one byte before where the checksum entry needs
to start, i.e. there's space for the tail entry, but it needs to be
reinitialized.  When that happens, we should proceed until d points to
that space so that the tail entry can be initialized.

Second, it's possible that we've been fed a directory block where the
entries end just short of the end of the block.  In this case, we need
to adjust the size of the last entry to point exactly to where the
dirent tail starts.  The current code requires that entries end
exactly on the block boundary, but this is not always the case with
damaged filesystems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass2.c
tests/f_corrupt_dirent_tail/expect.1 [new file with mode: 0644]
tests/f_corrupt_dirent_tail/expect.2 [new file with mode: 0644]
tests/f_corrupt_dirent_tail/image.gz [new file with mode: 0644]
tests/f_corrupt_dirent_tail/name [new file with mode: 0644]