mirror of https://github.com/vitalif/e2fsprogs
e2fsck: Fix salvage_directory when the last entry's rec_len is too big
Recently, one of our customers found this message in pass2 of e2fsck while doing some regression testing: "Entry '4, 0x695a, 0x81ff, 0x0040, 0x8320, 0xa192, 0x0021' in ??? (136554) has rec_len of 14200, should be 26908." Both the displayed rec_len and the "should be" value are bogus. The reason is that salvage_directory sets a offset beyond blocksize leading to bogus messages. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
48b0ea4140
commit
575307cc63
|
@ -675,11 +675,12 @@ static void salvage_directory(ext2_filsys fs,
|
|||
return;
|
||||
}
|
||||
/*
|
||||
* If the directory entry is a multiple of four, so it is
|
||||
* valid, let the previous directory entry absorb the invalid
|
||||
* one.
|
||||
* If the record length of the directory entry is a multiple
|
||||
* of four, and not too big, such that it is valid, let the
|
||||
* previous directory entry absorb the invalid one.
|
||||
*/
|
||||
if (prev && dirent->rec_len && (dirent->rec_len % 4) == 0) {
|
||||
if (prev && dirent->rec_len && (dirent->rec_len % 4) == 0 &&
|
||||
(*offset + dirent->rec_len <= fs->blocksize)) {
|
||||
prev->rec_len += dirent->rec_len;
|
||||
*offset += dirent->rec_len;
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
Pass 1: Checking inodes, blocks, and sizes
|
||||
Pass 2: Checking directory structure
|
||||
Directory inode 12, block 0, offset 60: directory corrupted
|
||||
Salvage? yes
|
||||
|
||||
Pass 3: Checking directory connectivity
|
||||
Pass 4: Checking reference counts
|
||||
Pass 5: Checking group summary information
|
||||
|
||||
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
|
||||
test_filesys: 15/16 files (0.0% non-contiguous), 23/100 blocks
|
||||
Exit status is 1
|
|
@ -0,0 +1,7 @@
|
|||
Pass 1: Checking inodes, blocks, and sizes
|
||||
Pass 2: Checking directory structure
|
||||
Pass 3: Checking directory connectivity
|
||||
Pass 4: Checking reference counts
|
||||
Pass 5: Checking group summary information
|
||||
test_filesys: 15/16 files (0.0% non-contiguous), 23/100 blocks
|
||||
Exit status is 0
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
salvage last directory entry
|
Loading…
Reference in New Issue