From: Rafał Miłecki Date: Tue, 13 Apr 2021 11:53:57 +0000 (+0200) Subject: firmware-utils: mkmylofw: fix blocks padding X-Git-Tag: mikrotik~2297 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d4f2c2914a6547ef6067dd0968c4970e913f17f0;p=openwrt%2Fstaging%2Fchunkeey.git firmware-utils: mkmylofw: fix blocks padding 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 --- diff --git a/tools/firmware-utils/src/mkmylofw.c b/tools/firmware-utils/src/mkmylofw.c index 5722365ee3..93eab202d9 100644 --- a/tools/firmware-utils/src/mkmylofw.c +++ b/tools/firmware-utils/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;