From 232cb45a6627c3483388d46096c70e8e454f0cfd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Tue, 13 Apr 2021 13:53:57 +0200 Subject: [PATCH] firmware-utils: mkmylofw: fix blocks padding MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The old code didn't make sense as it was using "len" variable which was guaranteed to be always 0. Loop right above broken code is: while (len > 0) { } With this recent ALIGN macro fix this resulted in subtracting block size from 0 and calling write_out_padding() with a negative length. To calculate amount of bytes needed for padding & alignment it should be enough to use % 4. Fixes: a2f66229450d ("firmware-utils: fix few random warnings") Signed-off-by: Rafał Miłecki --- src/mkmylofw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mkmylofw.c b/src/mkmylofw.c index 5722365..93eab20 100644 --- a/src/mkmylofw.c +++ b/src/mkmylofw.c @@ -583,7 +583,7 @@ write_out_file(FILE *outfile, struct fw_block *block, uint32_t *crc) fclose(f); /* align next block on a 4 byte boundary */ - len = ALIGN(len,4) - block->size; + len = block->size % 4; if (write_out_padding(outfile, len, 0xFF, crc)) return -1; -- 2.30.2