Skip to content

Commit

Permalink
sys/suit: avoid installing payload twice
Browse files Browse the repository at this point in the history
  • Loading branch information
fjmolinas committed Apr 25, 2022
1 parent c032e40 commit e66ad95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sys/include/suit.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ typedef struct {
#define SUIT_COMPONENT_STATE_FETCHED (1 << 0) /**< Component is fetched */
#define SUIT_COMPONENT_STATE_FETCH_FAILED (1 << 1) /**< Component fetched but failed */
#define SUIT_COMPONENT_STATE_VERIFIED (1 << 2) /**< Component is verified */
#define SUIT_COMPONENT_STATE_FINALIZED (1 << 3) /**< Component successfully installed */
#define SUIT_COMPONENT_STATE_INSTALLED (1 << 3) /**< Component is installed, but has not been verified */
#define SUIT_COMPONENT_STATE_FINALIZED (1 << 4) /**< Component successfully installed */
/** @} */

/**
Expand Down
10 changes: 8 additions & 2 deletions sys/suit/handlers_command_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,14 @@ static int _dtv_verify_image_match(suit_manifest_t *manifest, int key,
LOG_INFO("Starting digest verification against image\n");
res = _validate_payload(comp, digest, img_size);
if (res == SUIT_OK) {
LOG_INFO("Install correct payload\n");
suit_storage_install(comp->storage_backend, manifest);
if (!suit_component_check_flag(comp, SUIT_COMPONENT_STATE_INSTALLED)) {
LOG_INFO("Install correct payload\n");
suit_storage_install(comp->storage_backend, manifest);
suit_component_set_flag(comp, SUIT_COMPONENT_STATE_INSTALLED);
}
if (suit_component_check_flag(comp, SUIT_COMPONENT_STATE_INSTALLED)) {
LOG_INFO("Verified installed payload\n");
}
}
else {
LOG_INFO("Erasing bad payload\n");
Expand Down

0 comments on commit e66ad95

Please sign in to comment.