diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog index 53281b49..5e04ca7a 100644 --- a/avrdude/ChangeLog +++ b/avrdude/ChangeLog @@ -1,3 +1,12 @@ +2008-10-31 Joerg Wunsch + + * jtagmkII.c: Fix a serious memory corruption that happened when + using the JTAG ICE mkII (or AVR Dragon) in ISP mode. The wrong + set of per-programmer private data had been allocated (stk500v2 + vs. jtagmkII) which was too small to hold the actual data. + * jtagmkII.h: (Ditto.) + * stk500v2.c: (Ditto.) + 2008-07-29 Joerg Wunsch * jtagmkII.c: Implement Xmega JTAG support. diff --git a/avrdude/jtagmkII.c b/avrdude/jtagmkII.c index 13f5e3ff..44086bfc 100644 --- a/avrdude/jtagmkII.c +++ b/avrdude/jtagmkII.c @@ -130,7 +130,7 @@ static int jtagmkII_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char * value); static void jtagmkII_print_parms1(PROGRAMMER * pgm, const char * p); -static void jtagmkII_setup(PROGRAMMER * pgm) +void jtagmkII_setup(PROGRAMMER * pgm) { if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { fprintf(stderr, @@ -141,7 +141,7 @@ static void jtagmkII_setup(PROGRAMMER * pgm) memset(pgm->cookie, 0, sizeof(struct pdata)); } -static void jtagmkII_teardown(PROGRAMMER * pgm) +void jtagmkII_teardown(PROGRAMMER * pgm) { free(pgm->cookie); } diff --git a/avrdude/jtagmkII.h b/avrdude/jtagmkII.h index 9bdbae5d..32f520dd 100644 --- a/avrdude/jtagmkII.h +++ b/avrdude/jtagmkII.h @@ -38,6 +38,14 @@ void jtagmkII_dw_initpgm (PROGRAMMER * pgm); void jtagmkII_dragon_initpgm (PROGRAMMER * pgm); void jtagmkII_dragon_dw_initpgm (PROGRAMMER * pgm); +/* + * These functions are referenced from stk500v2.c for JTAG ICE mkII + * and AVR Dragon programmers running in one of the STK500v2 + * modi. + */ +void jtagmkII_setup(PROGRAMMER * pgm); +void jtagmkII_teardown(PROGRAMMER * pgm); + #ifdef __cplusplus } #endif diff --git a/avrdude/stk500v2.c b/avrdude/stk500v2.c index d2ef6473..5d598bf0 100644 --- a/avrdude/stk500v2.c +++ b/avrdude/stk500v2.c @@ -3482,8 +3482,8 @@ void stk500v2_jtagmkII_initpgm(PROGRAMMER * pgm) pgm->print_parms = stk500v2_print_parms; pgm->set_sck_period = stk500v2_set_sck_period_mk2; pgm->perform_osccal = stk500v2_perform_osccal; - pgm->setup = stk500v2_setup; - pgm->teardown = stk500v2_teardown; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; pgm->page_size = 256; } @@ -3513,8 +3513,8 @@ void stk500v2_dragon_isp_initpgm(PROGRAMMER * pgm) pgm->paged_load = stk500v2_paged_load; pgm->print_parms = stk500v2_print_parms; pgm->set_sck_period = stk500v2_set_sck_period_mk2; - pgm->setup = stk500v2_setup; - pgm->teardown = stk500v2_teardown; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; pgm->page_size = 256; } @@ -3546,8 +3546,8 @@ void stk500v2_dragon_pp_initpgm(PROGRAMMER * pgm) pgm->set_varef = stk500v2_set_varef; pgm->set_fosc = stk500v2_set_fosc; pgm->set_sck_period = stk500v2_set_sck_period_mk2; - pgm->setup = stk500v2_setup; - pgm->teardown = stk500v2_teardown; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; pgm->page_size = 256; } @@ -3579,8 +3579,8 @@ void stk500v2_dragon_hvsp_initpgm(PROGRAMMER * pgm) pgm->set_varef = stk500v2_set_varef; pgm->set_fosc = stk500v2_set_fosc; pgm->set_sck_period = stk500v2_set_sck_period_mk2; - pgm->setup = stk500v2_setup; - pgm->teardown = stk500v2_teardown; + pgm->setup = jtagmkII_setup; + pgm->teardown = jtagmkII_teardown; pgm->page_size = 256; }