avrdudes / avarice

AVaRICE is a program for interfacing the Atmel JTAG ICE to GDB to allow users to debug their embedded AVR target.
GNU General Public License v2.0
39 stars 13 forks source link

fix heap corruption on LP64 platforms #90

Open tlyu opened 2 years ago

tlyu commented 2 years ago

Mixing unsigned long and int on LP64 platforms caused the chunksize adjustment to be wrong for flash memory reads from "negative" addresses. This caused runaway reads and heap corruption, because chunksize was being adjusted to be greater than numBytes. Simplify the computation by computing the offset within the page using a mask, and use the difference between pageSize and offset to limit chunksize.

This is less necessary after the qXfer:memory-map:read support was added, but it's definitely needed in 2.13, and maybe some older GDB versions don't support qXfer:memory-map:read.

Fixes #107.

tlyu commented 11 months ago

Converted to draft, because jtag3rw.cc probably also needs a similar change.