ext4fs: fix "invalid extent block" error
authorIonut Nicu <ioan.nicu.ext@nsn.com>
Mon, 13 Jan 2014 11:00:08 +0000 (12:00 +0100)
committerChanho Park <chanho61.park@samsung.com>
Thu, 6 Aug 2015 04:33:41 +0000 (13:33 +0900)
For files where we actually have extent indexes following
an extent header (ext_block->eh_depth != 0), the do/while
loop from ext4fs_get_extent_block() does not select the
proper extent index structure.

For example, if we have:

ext_block->eh_depth = 1
ext_block->eh_entries = 1
fileblock = 0
index[0].ei_block = 0

the do/while loop will exit with i set to 0 and the
ext4fs_get_extent_block() function will return 0, even if
there was a valid extent index structure following the
header.

Signed-off-by: Ionut Nicu <ioan.nicu.ext@nsn.com>
Signed-off-by: Mathias Rulf <mathias.rulf@nsn.com>
fs/ext4/ext4_common.c

index 77c5111113f29254414594b2fb431d0d3e7f5183..cdaf8423f9e5df7c7142a9a8b3729bd20335d0d9 100644 (file)
@@ -1442,7 +1442,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block
                        i++;
                        if (i >= le16_to_cpu(ext_block->eh_entries))
                                break;
-               } while (fileblock > le32_to_cpu(index[i].ei_block));
+               } while (fileblock >= le32_to_cpu(index[i].ei_block));
 
                if (--i < 0)
                        return 0;