mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-23 17:46:33 +03:00
Ensure valid buf access
This commit is contained in:
@@ -894,6 +894,7 @@ static int avrftdi_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned
|
||||
static int avrftdi_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
int i;
|
||||
unsigned char buf[4];
|
||||
int polli = p->pollindex - 1, pollok = polli >= 0 && polli < (int) sizeof buf;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
@@ -906,7 +907,7 @@ static int avrftdi_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
pgm->cmd(pgm, buf, buf);
|
||||
if (buf[p->pollindex-1] != p->pollvalue) {
|
||||
if (pollok && buf[polli] != p->pollvalue) {
|
||||
pmsg_warning("program enable command not successful%s\n", i < 3? "; retrying": "");
|
||||
set_pin(pgm, PIN_AVR_RESET, ON);
|
||||
usleep(20);
|
||||
|
||||
Reference in New Issue
Block a user