ext2: check some more values for ext2_super_block
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk> Fixes #13401.
This commit is contained in:
parent
2ff144d005
commit
c8a27537a7
|
@ -202,9 +202,21 @@ DeviceOpener::GetSize(off_t* _size, uint32* _blockSize)
|
|||
bool
|
||||
ext2_super_block::IsValid()
|
||||
{
|
||||
// TODO: check some more values!
|
||||
if (Magic() != (uint32)EXT2_SUPER_BLOCK_MAGIC)
|
||||
if (Magic() != (uint32)EXT2_SUPER_BLOCK_MAGIC
|
||||
|| BlockShift() > 16
|
||||
|| BlocksPerGroup() != (1UL << BlockShift()) * 8
|
||||
|| InodeSize() > (1UL << BlockShift())
|
||||
|| RevisionLevel() > EXT2_MAX_REVISION
|
||||
|| ReservedGDTBlocks() > (1UL << BlockShift()) / 4)
|
||||
return false;
|
||||
if (Has64bitFeature()) {
|
||||
if (GroupDescriptorSize() > EXT2_BLOCK_GROUP_64BIT_SIZE || GroupDescriptorSize() < EXT2_BLOCK_GROUP_NORMAL_SIZE)
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (GroupDescriptorSize() != EXT2_BLOCK_GROUP_NORMAL_SIZE)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -194,6 +194,7 @@ struct ext2_super_block {
|
|||
#define EXT2_STATE_INVALID 0x02
|
||||
|
||||
#define EXT2_BLOCK_GROUP_NORMAL_SIZE 32
|
||||
#define EXT2_BLOCK_GROUP_64BIT_SIZE 64
|
||||
|
||||
// block group flags
|
||||
#define EXT2_BLOCK_GROUP_INODE_UNINIT 0x1
|
||||
|
|
Loading…
Reference in New Issue