file_simple: Allocate correct buffer size for writing sections out

The original size given to the "calloc" call did not account for the
necessity to pad section sizes to a multiple of 4 bytes. As such, every
time we wrote a section that did not have a size multiple of 4 we would
overflow the allocated buffer.

Fix the calloc call to account for that padding requirement.

Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
This commit is contained in:
Paul Olaru 2023-05-30 12:29:52 +03:00 committed by Daniel Baluta
parent 1ea1327b9c
commit 649b0a6790
1 changed files with 1 additions and 1 deletions

View File

@ -71,7 +71,7 @@ static int write_block(struct image *image, struct manifest_module *module,
return file_error("Write header failed", image->out_file);
/* alloc data data */
buffer = calloc(1, section->size);
buffer = calloc(1, block.size);
if (!buffer)
return -ENOMEM;