Skip to content

Commit

Permalink
fix(core/bootloader): fix repeated firmware upload
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
TychoVrahe committed Aug 29, 2024
1 parent 1148b43 commit 68398d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/embed/bootloader/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,11 @@ int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size,
memcpy(&hdr, received_hdr, sizeof(hdr));

size_t headers_end = IMAGE_HEADER_SIZE + vhdr.hdrlen;
headers_offset = IMAGE_CODE_ALIGN(IMAGE_HEADER_SIZE + vhdr.hdrlen);
size_t tmp_headers_offset =
IMAGE_CODE_ALIGN(IMAGE_HEADER_SIZE + vhdr.hdrlen);

// check padding between headers and the code
for (size_t i = headers_end; i < headers_offset; i++) {
for (size_t i = headers_end; i < tmp_headers_offset; i++) {
if (CHUNK_BUFFER_PTR[i] != 0) {
MSG_SEND_INIT(Failure);
MSG_SEND_ASSIGN_VALUE(code, FailureType_Failure_ProcessError);
Expand Down Expand Up @@ -704,6 +705,7 @@ int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size,
NULL);
}

headers_offset = IMAGE_CODE_ALIGN(IMAGE_HEADER_SIZE + vhdr.hdrlen);
read_offset = IMAGE_INIT_CHUNK_SIZE;

// request the rest of the first chunk
Expand Down

0 comments on commit 68398d4

Please sign in to comment.