diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-08-23 13:23:58 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-08-23 13:44:13 +0200 |
commit | a38b1cbc5e917d945340a6dd9dba4274a2eb8789 (patch) | |
tree | be3a59cc2c3013c95fe5899306232dabff25c9de /lib/sqfs/write_table.c | |
parent | 029a8db2701afb0653c6e789c878bb768ceb87e1 (diff) |
Size accounting + alloc() overflow checking, round #2
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/write_table.c')
-rw-r--r-- | lib/sqfs/write_table.c | 4 |
1 files changed, 2 insertions, 2 deletions
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; |