From a38b1cbc5e917d945340a6dd9dba4274a2eb8789 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 23 Aug 2019 13:23:58 +0200 Subject: Size accounting + alloc() overflow checking, round #2 Signed-off-by: David Oberhollenzer --- lib/sqfs/read_table.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/sqfs/read_table.c') diff --git a/lib/sqfs/read_table.c b/lib/sqfs/read_table.c index 6efd401..d486c97 100644 --- a/lib/sqfs/read_table.c +++ b/lib/sqfs/read_table.c @@ -18,7 +18,7 @@ void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size, uint64_t location, uint64_t lower_limit, uint64_t upper_limit) { - size_t diff, block_count, list_size, blk_idx = 0; + size_t diff, block_count, blk_idx = 0; uint64_t start, *locations; meta_reader_t *m; void *data, *ptr; @@ -35,8 +35,7 @@ void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size, if ((table_size % SQFS_META_BLOCK_SIZE) != 0) ++block_count; - list_size = sizeof(uint64_t) * block_count; - locations = malloc(list_size); + locations = alloc_array(sizeof(uint64_t), block_count); if (locations == NULL) { perror("allocation table location list"); @@ -44,7 +43,7 @@ void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size, } if (read_data_at("reading table locations", location, - fd, locations, list_size)) { + fd, locations, sizeof(uint64_t) * block_count)) { goto fail_idx; } -- cgit v1.2.3