From: Michel Pollet Date: Wed, 27 Nov 2013 16:50:46 +0000 (+0000) Subject: core: Fix a possible buffer overrun X-Git-Tag: v1.2~52 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=f87c0ca090b1227bc3940b9381e9736114547c3c;p=sx%2Fsimavr.git core: Fix a possible buffer overrun From bsekisser@github Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/sim_avr.c b/simavr/sim/sim_avr.c index 6ece88d..894bc0b 100644 --- a/simavr/sim/sim_avr.c +++ b/simavr/sim/sim_avr.c @@ -177,7 +177,7 @@ void avr_set_console_register(avr_t * avr, avr_io_addr_t addr) void avr_loadcode(avr_t * avr, uint8_t * code, uint32_t size, avr_flashaddr_t address) { - if (size > avr->flashend+1) { + if ((address + size) > avr->flashend+1) { AVR_LOG(avr, LOG_ERROR, "avr_loadcode(): Attempted to load code of size %d but flash size is only %d.\n", size, avr->flashend + 1); abort();