Skip to content

Commit

Permalink
system/fastboot: Fix that total_chunks of sparse_header maybe error
Browse files Browse the repository at this point in the history
when size of image passed to command "fastboot flash" is not 4KB aligned.

Signed-off-by: wangjianyu3 <[email protected]>
  • Loading branch information
JianyuWang0623 committed Sep 10, 2024
1 parent 7873f36 commit 0db1389
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions system/fastboot/fastboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ static int
fastboot_flash_program(FAR struct fastboot_ctx_s *context, int fd)
{
FAR char *chunk_ptr = context->download_buffer;
FAR char *end_ptr = chunk_ptr + context->download_size;
FAR struct fastboot_sparse_header_s *sparse;
uint32_t chunk_num;
int ret = OK;
Expand All @@ -382,10 +383,9 @@ fastboot_flash_program(FAR struct fastboot_ctx_s *context, int fd)
}

chunk_num = sparse->total_chunks;

chunk_ptr += FASTBOOT_SPARSE_HEADER;

while (chunk_num--)
while (chunk_ptr < end_ptr && chunk_num--)
{
FAR struct fastboot_chunk_header_s *chunk =
(FAR struct fastboot_chunk_header_s *)chunk_ptr;
Expand Down

0 comments on commit 0db1389

Please sign in to comment.