mirror of https://github.com/wolfSSL/wolfBoot.git
minor fix in case of empty external partition
parent
1970fbdd2e
commit
6a5ee45182
|
@ -211,6 +211,7 @@ int wolfBoot_open_image(struct wolfBoot_image *img, uint8_t part)
|
||||||
if (!img)
|
if (!img)
|
||||||
return -1;
|
return -1;
|
||||||
memset(img, 0, sizeof(struct wolfBoot_image));
|
memset(img, 0, sizeof(struct wolfBoot_image));
|
||||||
|
img->part = part;
|
||||||
if (part == PART_SWAP) {
|
if (part == PART_SWAP) {
|
||||||
img->part = PART_SWAP;
|
img->part = PART_SWAP;
|
||||||
img->hdr = (void *)WOLFBOOT_PARTITION_SWAP_ADDRESS;
|
img->hdr = (void *)WOLFBOOT_PARTITION_SWAP_ADDRESS;
|
||||||
|
@ -237,7 +238,6 @@ int wolfBoot_open_image(struct wolfBoot_image *img, uint8_t part)
|
||||||
|
|
||||||
if (*size >= WOLFBOOT_PARTITION_SIZE)
|
if (*size >= WOLFBOOT_PARTITION_SIZE)
|
||||||
return -1;
|
return -1;
|
||||||
img->part = part;
|
|
||||||
img->hdr_ok = 1;
|
img->hdr_ok = 1;
|
||||||
img->fw_size = *size;
|
img->fw_size = *size;
|
||||||
img->fw_base = img->hdr + IMAGE_HEADER_SIZE;
|
img->fw_base = img->hdr + IMAGE_HEADER_SIZE;
|
||||||
|
|
|
@ -89,7 +89,7 @@ static int wolfBoot_update(int fallback_allowed)
|
||||||
if ((update.fw_size + IMAGE_HEADER_SIZE) > total_size)
|
if ((update.fw_size + IMAGE_HEADER_SIZE) > total_size)
|
||||||
total_size = update.fw_size + IMAGE_HEADER_SIZE;
|
total_size = update.fw_size + IMAGE_HEADER_SIZE;
|
||||||
|
|
||||||
if (total_size < IMAGE_HEADER_SIZE)
|
if (total_size <= IMAGE_HEADER_SIZE)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Check the first sector to detect interrupted update */
|
/* Check the first sector to detect interrupted update */
|
||||||
|
|
Loading…
Reference in New Issue