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
7 changes: 5 additions & 2 deletions src/wh_client_she.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ int wh_Client_SheSecureBoot(whClientContext* c, uint8_t* bootloader,
while (ret == 0 && bootloaderSent < bootloaderLen) {
uint8_t* in;
uint32_t justSent;
uint32_t remaining;
static const uint32_t maxChunk =
WOLFHSM_CFG_COMM_DATA_LEN - sizeof(*updateReq);

if (initResp->rc != WH_SHE_ERC_NO_ERROR) {
return initResp->rc;
Expand All @@ -168,8 +171,8 @@ int wh_Client_SheSecureBoot(whClientContext* c, uint8_t* bootloader,
in = (uint8_t*)(updateReq + 1);

/* send what's left in the size available */
updateReq->sz = ((bootloaderLen - bootloaderSent) %
(WOLFHSM_CFG_COMM_DATA_LEN - sizeof(*updateReq)));
remaining = bootloaderLen - bootloaderSent;
updateReq->sz = (remaining > maxChunk) ? maxChunk : remaining;

justSent = updateReq->sz;
memcpy(in, bootloader + bootloaderSent, updateReq->sz);
Expand Down
Loading