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/write_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sqfs/write_table.c') diff --git a/lib/sqfs/write_table.c b/lib/sqfs/write_table.c index 2e55a26..aea5058 100644 --- a/lib/sqfs/write_table.c +++ b/lib/sqfs/write_table.c @@ -27,8 +27,7 @@ int sqfs_write_table(int outfd, sqfs_super_t *super, compressor_t *cmp, 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("writing table"); @@ -64,6 +63,7 @@ int sqfs_write_table(int outfd, sqfs_super_t *super, compressor_t *cmp, /* write location list */ *start = super->bytes_used; + list_size = sizeof(uint64_t) * block_count; if (write_data("writing table locations", outfd, locations, list_size)) goto out; -- cgit v1.2.3