Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boot/boot_serial/src/boot_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ bs_upload(char *buf, int len)
}

#if !defined(MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD)
if (img_num > BOOT_IMAGE_NUMBER) {
if (img_num >= BOOT_IMAGE_NUMBER) {
rc = MGMT_ERR_ENOENT;
goto out;
}
Expand Down
6 changes: 6 additions & 0 deletions boot/zephyr/include/sysflash/sysflash.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef __SYSFLASH_H__
#define __SYSFLASH_H__

#include <errno.h>
#include <mcuboot_config/mcuboot_config.h>
#include <zephyr/devicetree.h>
#include <zephyr/storage/flash_map.h>
Expand Down Expand Up @@ -76,6 +77,11 @@ static inline uint32_t __flash_area_ids_for_slot(int img, int slot)
static const int all_slots[] = {
FOR_EACH_NONEMPTY_TERM(PARTITION_ID, (,), ALL_AVAILABLE_SLOTS)
};

if (img < 0 || img >= MCUBOOT_IMAGE_NUMBER || slot < 0 || slot > 1) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a define for the secondary image that should be used here

return -EINVAL; /* flash_area_open will fail on that */
}

return all_slots[img * 2 + slot];
};

Expand Down
Loading