From 1e4d78f17dc6151bc813630982ecec3445b08b96 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Thu, 3 Aug 2023 14:42:37 +0200 Subject: [PATCH] Prevent reading more bytes than the SIB memory has --- src/jtag3.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/jtag3.c b/src/jtag3.c index 75da7b01..f7927fea 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -2173,6 +2173,11 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM if (pgm->flag & PGM_FL_IS_DW) unsupp = 1; } else if (str_eq(mem->desc, "sib")) { + if(addr >= AVR_SIBLEN) { + pmsg_error("cannot read byte from %s sib as address 0x%04lx outside range [0, 0x%04x]\n", + p->desc, addr, AVR_SIBLEN-1); + return -1; + } if(!*PDATA(pgm)->sib_string) { pmsg_error("cannot read byte from %s sib as memory not initialised\n", p->desc); return -1;