fs/ntfs3: Fix integer overflow in multiplication

The multiplication of the u32 data_size with a int is being performed
using 32 bit arithmetic however the results is being assigned to the
variable nbits that is a size_t (64 bit) value. Fix a potential
integer overflow by casting the u32 value to a size_t before the
multiply to use a size_t sized bit multiply operation.

Addresses-Coverity: ("Unintentional integer overflow")
Fixes: 82cae269cf ("fs/ntfs3: Add initialization of super block")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
Colin Ian King 2021-08-16 17:30:25 +01:00 committed by Konstantin Komarov
parent 87790b6534
commit 71eeb6ace8
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6

View File

@ -2012,7 +2012,7 @@ static int indx_shrink(struct ntfs_index *indx, struct ntfs_inode *ni,
unsigned long pos; unsigned long pos;
const unsigned long *bm = resident_data(b); const unsigned long *bm = resident_data(b);
nbits = le32_to_cpu(b->res.data_size) * 8; nbits = (size_t)le32_to_cpu(b->res.data_size) * 8;
if (bit >= nbits) if (bit >= nbits)
return 0; return 0;