Skip to content

Commit 206c7e7

Browse files
committed
bootutil: loader: Remove encrypted/compressed images without support
Checks if images have compressed or encrypted image flags and, if so, and those options are not enabled in that MCUboot build, will class the images as invalid and delete them (these images cannot be used without support anyway) Signed-off-by: Jamie McCrae <[email protected]>
1 parent 0c1ddf7 commit 206c7e7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

boot/bootutil/src/loader.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,9 @@ split_image_check(struct image_header *app_hdr,
860860
* Check that this is a valid header. Valid means that the magic is
861861
* correct, and that the sizes/offsets are "sane". Sane means that
862862
* there is no overflow on the arithmetic, and that the result fits
863-
* within the flash area we are in.
863+
* within the flash area we are in. Also check the flags in the image
864+
* and class the image as invalid if flags for encryption/compression
865+
* are present but these features are not enabled.
864866
*/
865867
static bool
866868
boot_is_header_valid(const struct image_header *hdr, const struct flash_area *fap,
@@ -882,6 +884,18 @@ boot_is_header_valid(const struct image_header *hdr, const struct flash_area *fa
882884
return false;
883885
}
884886

887+
#if !defined(MCUBOOT_ENC_IMAGES)
888+
if (IS_ENCRYPTED(hdr)) {
889+
return false;
890+
}
891+
#endif
892+
893+
#if !defined(MCUBOOT_DECOMPRESS_IMAGES)
894+
if (IS_COMPRESSED(hdr)) {
895+
return false;
896+
}
897+
#endif
898+
885899
return true;
886900
}
887901

0 commit comments

Comments
 (0)