minor fix in case of empty external partition

pull/20/head
Daniele Lacamera 2019-09-18 11:53:37 +02:00 committed by Daniele Lacamera
parent 1970fbdd2e
commit 6a5ee45182
2 changed files with 2 additions and 2 deletions

View File

@ -211,6 +211,7 @@ int wolfBoot_open_image(struct wolfBoot_image *img, uint8_t part)
if (!img)
return -1;
memset(img, 0, sizeof(struct wolfBoot_image));
img->part = part;
if (part == PART_SWAP) {
img->part = PART_SWAP;
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)
return -1;
img->part = part;
img->hdr_ok = 1;
img->fw_size = *size;
img->fw_base = img->hdr + IMAGE_HEADER_SIZE;

View File

@ -89,7 +89,7 @@ static int wolfBoot_update(int fallback_allowed)
if ((update.fw_size + IMAGE_HEADER_SIZE) > total_size)
total_size = update.fw_size + IMAGE_HEADER_SIZE;
if (total_size < IMAGE_HEADER_SIZE)
if (total_size <= IMAGE_HEADER_SIZE)
return -1;
/* Check the first sector to detect interrupted update */