If the cluster size is smaller than the block size, this can result in
a negative shift, which is undefined. When such a file system is
opened, immediately return an error indicating that the file system is
corrupted.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
}
}
- if (fs->super->s_log_block_size >
- (unsigned) (EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) {
+ if ((fs->super->s_log_block_size >
+ (unsigned) (EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) ||
+ (fs->super->s_log_cluster_size >
+ (unsigned) (EXT2_MAX_CLUSTER_LOG_SIZE - EXT2_MIN_CLUSTER_LOG_SIZE)) ||
+ (fs->super->s_log_block_size > fs->super->s_log_cluster_size)) {
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}