mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-18 02:44:37 +00:00
squashfs: Fix integer overflow in sqfs_inode_size()
A carefully crafted squashfs filesystem can exhibit an extremly large inode size and overflow the calculation in sqfs_inode_size(). As a consequence, the squashfs driver will read from wrong locations. Fix by using __builtin_add_overflow() to detect the overflow. Signed-off-by: Richard Weinberger <richard@nod.at> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
parent
233945eba6
commit
c8e929e575
1 changed files with 7 additions and 2 deletions
|
@ -78,11 +78,16 @@ int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size)
|
|||
|
||||
case SQFS_SYMLINK_TYPE:
|
||||
case SQFS_LSYMLINK_TYPE: {
|
||||
int size;
|
||||
|
||||
struct squashfs_symlink_inode *symlink =
|
||||
(struct squashfs_symlink_inode *)inode;
|
||||
|
||||
return sizeof(*symlink) +
|
||||
get_unaligned_le32(&symlink->symlink_size);
|
||||
if (__builtin_add_overflow(sizeof(*symlink),
|
||||
get_unaligned_le32(&symlink->symlink_size), &size))
|
||||
return -EINVAL;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
case SQFS_BLKDEV_TYPE:
|
||||
|
|
Loading…
Add table
Reference in a new issue