From f0a23398225d828b8d1ae7438979760b47404cd6 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 9 May 2022 14:46:50 -0400 Subject: [PATCH] canboot_main: Make sure to not overwrite the bootloader itself Signed-off-by: Kevin O'Connor --- src/canboot_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/canboot_main.c b/src/canboot_main.c index f441c9f..a5e1a54 100644 --- a/src/canboot_main.c +++ b/src/canboot_main.c @@ -86,6 +86,10 @@ process_write_block(uint32_t* data, uint8_t data_len) { return; } uint32_t block_address = le32_to_cpu(data[0]); + if (block_address < CONFIG_APPLICATION_START) { + canboot_sendf(cerr, 8); + return; + } uint32_t flash_page_size = flash_get_page_size(); uint32_t page_pos = block_address % flash_page_size; memcpy(&page_buffer[page_pos], (uint8_t *)&data[1], CONFIG_BLOCK_SIZE);