diff --git a/ChangeLog b/ChangeLog index 6a10637e..5b83659c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-09-18 Joerg Wunsch + + Submitted by Joel Ray Holveck + patch #9732: usbtiny_paged_load overflows buffer e.g. when reading EEPROM + * usbtiny.c (usbtiny_paged_load, usbtiny_paged_write): ensure chunk + does not overflow memory area + 2020-09-16 Joerg Wunsch Submitted by Adrian Klieber: diff --git a/NEWS b/NEWS index b8ac39bf..22ed6aba 100644 --- a/NEWS +++ b/NEWS @@ -72,6 +72,7 @@ Current: patch #9819: Address several leaks in SVN rev 1429 patch #9820: Fix some out-of-bounds/uninitialized issues patch #9818: correct typos in SVN rev 1429 + patch #9732: usbtiny_paged_load overflows buffer e.g. when reading EEPROM * Internals: - New avrdude.conf keyword "family_id", used to verify SIB attributes diff --git a/usbtiny.c b/usbtiny.c index f28dd473..080c9df2 100644 --- a/usbtiny.c +++ b/usbtiny.c @@ -641,6 +641,9 @@ static int usbtiny_paged_load (PROGRAMMER * pgm, AVRPART * p, AVRMEM* m, for (; addr < maxaddr; addr += chunk) { chunk = PDATA(pgm)->chunk_size; // start with the maximum chunk size possible + if (addr + chunk > maxaddr) { + chunk = maxaddr - addr; + } // Send the chunk of data to the USBtiny with the function we want // to perform @@ -696,6 +699,9 @@ static int usbtiny_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, for (; addr < maxaddr; addr += chunk) { // start with the max chunk size chunk = PDATA(pgm)->chunk_size; + if (addr + chunk > maxaddr) { + chunk = maxaddr - addr; + } // we can only write a page at a time anyways if (m->paged && chunk > page_size)