From 248b109c9a5374299d839878aeaa3c0b3b3fac2d Mon Sep 17 00:00:00 2001 From: slurdge Date: Tue, 9 Jul 2019 21:57:54 +0200 Subject: [PATCH] Check if bootloader segment is within bounds --- client/flash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/flash.c b/client/flash.c index 891efaeb3..d8ac983e7 100644 --- a/client/flash.c +++ b/client/flash.c @@ -173,6 +173,10 @@ static int check_segs(flash_file_t *ctx, int can_write_bl) { PrintAndLogEx(ERR, "Attempted to write bootloader but bootloader writes are not enabled"); return -1; } + if (can_write_bl && seg->start < BOOTLOADER_END && (seg->start + seg->length > BOOTLOADER_END)) { + PrintAndLogEx(ERR, "Error: Segment is outside of bootloader bounds"); + return -1; + } } return 0; }