Skip to content

Commit b245ccd

Browse files
committed
[nrf noup] zephyr: Fix compressed image support
fixup! [nrf noup] zephyr: Add support for compressed image updates Fixes some issues with compressed image update support Signed-off-by: Jamie McCrae <[email protected]>
1 parent 10f3dbe commit b245ccd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

boot/bootutil/src/image_validate.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,16 @@ bootutil_img_validate(struct enc_key_data *enc_state, int image_index,
508508
found_flag = &found_decompressed_sha;
509509
break;
510510
case IMAGE_TLV_DECOMP_SIGNATURE:
511-
expected_size = SIG_BUF_SIZE;
512511
found_flag = &found_decompressed_signature;
513512
break;
514513
default:
515514
continue;
516515
};
517516

518-
if (len != expected_size) {
517+
if (type == IMAGE_TLV_DECOMP_SIGNATURE && !EXPECTED_SIG_LEN(len)) {
518+
rc = -1;
519+
goto out;
520+
} else if (type != IMAGE_TLV_DECOMP_SIGNATURE && len != expected_size) {
519521
rc = -1;
520522
goto out;
521523
}

boot/zephyr/decompression.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ int boot_copy_region_decompress(struct boot_loader_state *state, const struct fl
10271027

10281028
/* Check if we have unwritten data buffered up and, if so, write it out */
10291029
if (decomp_buf_size > 0) {
1030-
uint32_t write_padding_size = decomp_buf_size % write_alignment;
1030+
uint32_t write_padding_size = write_alignment - (decomp_buf_size % write_alignment);
10311031

10321032
/* Check if additional write padding should be applied to meet the minimum write size */
10331033
if (write_padding_size) {

0 commit comments

Comments
 (0)