Skip to content

Commit b3f3b53

Browse files
dgarskedanielinux
authored andcommitted
Fix for image_open wolfBoot_get_blob_version print. Added NULL protection on wolfBoot_get_blob_version.
1 parent 094dc22 commit b3f3b53

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ int wolfBoot_open_image_address(struct wolfBoot_image *img, uint8_t *image)
886886
(img->part == PART_BOOT) ? "Boot" : "Update",
887887
img->hdr,
888888
(unsigned int)img->fw_size,
889-
wolfBoot_get_blob_version(img->hdr));
889+
wolfBoot_get_blob_version(image));
890890

891891
return 0;
892892
}

src/libwolfboot.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static int RAMFUNCTION nvm_select_fresh_sector(int part)
239239
sel = 0;
240240

241241
/* Select the sector with more flags set. Partition flag is at offset '4'.
242-
* Sector flags begin from offset '5'.
242+
* Sector flags begin from offset '5'.
243243
*/
244244
for (off = 4; off < WOLFBOOT_SECTOR_SIZE; off++) {
245245
volatile uint8_t byte_0 = get_base_offset(base, off);
@@ -1018,6 +1018,8 @@ uint32_t wolfBoot_get_blob_version(uint8_t *blob)
10181018
uint32_t *volatile version_field = NULL;
10191019
uint32_t *magic = NULL;
10201020
uint8_t *img_bin = blob;
1021+
if (blob == NULL)
1022+
return 0;
10211023
#if defined(EXT_ENCRYPTED) && defined(MMU)
10221024
if (!encrypt_initialized)
10231025
if (crypto_init() < 0)
@@ -1870,15 +1872,16 @@ int wolfBoot_ram_decrypt(uint8_t *src, uint8_t *dst)
18701872
uint32_t dst_offset = 0, iv_counter = 0;
18711873
uint32_t magic, len;
18721874

1873-
18741875
if (!encrypt_initialized) {
18751876
if (crypto_init() < 0) {
1877+
wolfBoot_printf("Error initializing crypto!\n");
18761878
return -1;
18771879
}
18781880
}
18791881

18801882
/* Attempt to decrypt firmware header */
18811883
if (decrypt_header(src) != 0) {
1884+
wolfBoot_printf("Error decrypting header at %p!\n", src);
18821885
return -1;
18831886
}
18841887
len = *((uint32_t*)(dec_hdr + sizeof(uint32_t)));

src/update_flash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ static int wolfBoot_swap_and_final_erase(int resume)
219219
+ ENCRYPT_KEY_SIZE + ENCRYPT_NONCE_SIZE
220220
#endif
221221
];
222+
222223
/* open partitions (ignore failure) */
223224
wolfBoot_open_image(boot, PART_BOOT);
224225
wolfBoot_open_image(update, PART_UPDATE);

0 commit comments

Comments
 (0)