Submitted by Jon Thacker:

patch #9253: Fix for giving terminal_mode commands more than 20 arguments
* term.c (tokenize): fix realloc usage, pointer returned not necessarily
the same as pointer passed



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1471 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2021-11-12 22:11:49 +00:00
parent db7249bf57
commit 3d1b0ff308
3 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2021-11-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Jon Thacker:
patch #9253: Fix for giving terminal_mode commands more than 20 arguments
* term.c (tokenize): fix realloc usage, pointer returned not necessarily
the same as pointer passed
2021-11-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Martino Facchin:

1
NEWS
View File

@ -105,6 +105,7 @@ Current:
patch #10017: uspasp / tpi: Automatically clear configuration byte (fuse) before writing it
patch #8957: Allow reading prodsig memory from stk500v2 on xmega devices
patch #9110: Let reserved fuse bits to be read as *don't care*
patch #9253: Fix for giving terminal_mode commands more than 20 arguments
* Internals:
- New avrdude.conf keyword "family_id", used to verify SIB attributes

9
term.c
View File

@ -780,11 +780,12 @@ static int cmd_verbose(PROGRAMMER * pgm, struct avrpart * p,
static int tokenize(char * s, char *** argv)
{
int i, n, l, nargs, offset;
int i, n, l, k, nargs, offset;
int len, slen;
char * buf;
int bufsize;
char ** bufv;
char * bufp;
char * q, * r;
char * nbuf;
char ** av;
@ -821,9 +822,15 @@ static int tokenize(char * s, char *** argv)
/* realloc space for another 20 args */
bufsize += 20;
nargs += 20;
bufp = buf;
buf = realloc(buf, bufsize);
bufv = realloc(bufv, nargs*sizeof(char *));
nbuf = &buf[l];
/* correct bufv pointers */
k = buf - bufp;
for (i=0; i<n; i++) {
bufv[i] = bufv[i] + k;
}
for (i=n; i<nargs; i++)
bufv[i] = NULL;
}