Skip to content

Commit 058612c

Browse files
ahasztagtomchy
authored andcommitted
suit: Fix suit storage envelope
For the first operation the header size was checked before the offset was reset. Signed-off-by: Artur Hadasz <[email protected]>
1 parent dee8fe4 commit 058612c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/suit/storage/src/suit_storage_envelope.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ static suit_plat_err_t save_envelope_partial(uint8_t *area_addr, size_t area_siz
4848
return SUIT_PLAT_ERR_HW_NOT_READY;
4949
}
5050

51-
if (size >= (area_size - offset)) {
52-
return SUIT_PLAT_ERR_INVAL;
53-
}
54-
5551
if (reset) {
5652
buf_fill_level = 0;
5753
offset = 0;
@@ -61,6 +57,10 @@ static suit_plat_err_t save_envelope_partial(uint8_t *area_addr, size_t area_siz
6157
err = flash_erase(fdev, suit_plat_mem_nvm_offset_get(area_addr), area_size);
6258
}
6359

60+
if (size >= (area_size - offset)) {
61+
return SUIT_PLAT_ERR_INVAL;
62+
}
63+
6464
/* Require to set reset flag before changing envelope index. */
6565
if ((current_area_addr == NULL) || (area_addr != current_area_addr)) {
6666
LOG_ERR("It is required to set reset flag to change the write address.");

0 commit comments

Comments
 (0)