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
35 stars 11 forks source link

[patch #12] Fix segfault when programming with .fuses section #46

Closed avrs-admin closed 2 years ago

avrs-admin commented 2 years ago

suudy 2009-08-21 21:08:51

Avarice crashes when the .fuses section is present in the ELF when programming. The simple fix (for the segfault) is to have get_section_addr() return 0xffffff when an invalid section address is discovered. This prevents jtag_create_image() from overrunning the image->image buffer.

avarice-fuses-segfault-fix.patch

This issue was migrated from https://sourceforge.net/p/avarice/patches/12/

avrs-admin commented 2 years ago

suudy 2009-08-21 22:46:46

This bug exists, regardless of the section. If the .lock section is present (and the .fuses is not) this crash would occur. This attached patch fixes it in all cases.

The root cause is the fact that sectmemtype is not initialized. After the if/else if chain it could be anything (depending upon the stack). In the crash I've seen it is 0, which ends up being MEM_FLASH. Instead the if/else if chain should be terminated with an else that returns an 0xffffff indicating the section is not to be used.

avrs-admin commented 2 years ago

joerg_wunsch 2011-08-30 13:51:52

avrs-admin commented 2 years ago

joerg_wunsch 2011-08-30 13:51:52

Thanks, applied! (Also had to apply it to src/jtagprog.cc, just in case.)