u32 src_len, dest_offset = 0;
unsigned long dest_len = 0;
bool compressed;
+ size_t buf_size;
table_size = get_unaligned_le64(&sblk->directory_table_start) -
get_unaligned_le64(&sblk->inode_table_start);
sblk->directory_table_start, &table_offset);
/* Allocate a proper sized buffer (itb) to store the inode table */
- itb = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+ if (__builtin_mul_overflow(n_blks, ctxt.cur_dev->blksz, &buf_size))
+ return -EINVAL;
+
+ itb = malloc_cache_aligned(buf_size);
if (!itb)
return -ENOMEM;
u32 src_len, dest_offset = 0;
unsigned long dest_len = 0;
bool compressed;
+ size_t buf_size;
*dir_table = NULL;
*pos_list = NULL;
sblk->fragment_table_start, &table_offset);
/* Allocate a proper sized buffer (dtb) to store the directory table */
- dtb = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+ if (__builtin_mul_overflow(n_blks, ctxt.cur_dev->blksz, &buf_size))
+ return -EINVAL;
+
+ dtb = malloc_cache_aligned(buf_size);
if (!dtb)
return -ENOMEM;
unsigned long dest_len;
struct fs_dirent *dent;
unsigned char *ipos;
+ size_t buf_size;
*actread = 0;
table_offset = frag_entry.start - (start * ctxt.cur_dev->blksz);
n_blks = DIV_ROUND_UP(table_size + table_offset, ctxt.cur_dev->blksz);
- fragment = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+ if (__builtin_mul_overflow(n_blks, ctxt.cur_dev->blksz, &buf_size))
+ return -EINVAL;
+
+ fragment = malloc_cache_aligned(buf_size);
if (!fragment) {
ret = -ENOMEM;