From 3a748dfc1cc28878b5c0ffc1042c3efb3d26360e Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Sun, 10 Aug 2014 18:44:42 -0400 Subject: [PATCH] e2fsck: use the correct block size when salvaging directories Now that the directory salvaging operation is fed the block size, teach pass 2 that it should use the size of the inline data if the directory is inline_data. Without this, it'll "fix" inline directories by setting the rec_len to something approaching the FS blocksize, which is clearly wrong. Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- e2fsck/pass2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index d56b4c8..abf95bd 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -979,11 +979,17 @@ skip_checksum: problem = 0; if (!inline_data_size || dot_state > 1) { + size_t max_block_size = fs->blocksize - de_csum_size; + + if (inline_data_size) + max_block_size = inline_data_size; dirent = (struct ext2_dir_entry *) (buf + offset); (void) ext2fs_get_rec_len(fs, dirent, &rec_len); cd->pctx.dirent = dirent; cd->pctx.num = offset; if (((offset + rec_len) > fs->blocksize) || + (inline_data_size > 0 && + (offset + rec_len) > inline_data_size) || (rec_len < 12) || ((rec_len % 4) != 0) || ((ext2fs_dirent_name_len(dirent) + 8) > rec_len)) { @@ -991,8 +997,7 @@ skip_checksum: &cd->pctx)) { salvage_directory(fs, dirent, prev, &offset, - fs->blocksize - - de_csum_size); + max_block_size); dir_modified++; continue; } else -- 1.8.3.1