disallow $ in printf formats
This commit is contained in:
parent
0f4e1ba922
commit
22aff9e657
7
FIXES
7
FIXES
@ -25,6 +25,13 @@ THIS SOFTWARE.
|
||||
This file lists all bug fixes, changes, etc., made since the AWK book
|
||||
was sent to the printers in August, 1987.
|
||||
|
||||
Aug 27, 2018:
|
||||
Disallow '$' in printf formats; arguments evaluated in order
|
||||
and printed in order.
|
||||
|
||||
Added some casts to silence warnings on debugging printfs.
|
||||
(Thanks, Arnold.)
|
||||
|
||||
Aug 23, 2018:
|
||||
A long list of fixes courtesy of Arnold Robbins,
|
||||
to whom profound thanks.
|
||||
|
BIN
awktest.tar
BIN
awktest.tar
Binary file not shown.
9
run.c
9
run.c
@ -114,7 +114,7 @@ int adjbuf(char **pbuf, int *psiz, int minlen, int quantum, char **pbptr,
|
||||
if (rminlen)
|
||||
minlen += quantum - rminlen;
|
||||
tbuf = (char *) realloc(*pbuf, minlen);
|
||||
dprintf( ("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf) );
|
||||
dprintf( ("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, (void *) *pbuf, (void *) tbuf) );
|
||||
if (tbuf == NULL) {
|
||||
if (whatrtn)
|
||||
FATAL("out of memory in %s", whatrtn);
|
||||
@ -859,6 +859,9 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co
|
||||
FATAL("format item %.30s... ran format() out of memory", os);
|
||||
if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L')
|
||||
break; /* the ansi panoply */
|
||||
if (*s == '$') {
|
||||
FATAL("'$' not permitted in awk formats");
|
||||
}
|
||||
if (*s == '*') {
|
||||
x = execute(a);
|
||||
a = a->nnext;
|
||||
@ -874,7 +877,6 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co
|
||||
if (fmtwd < 0)
|
||||
fmtwd = -fmtwd;
|
||||
adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format4");
|
||||
|
||||
switch (*s) {
|
||||
case 'a': case 'A':
|
||||
if (have_a_format)
|
||||
@ -1641,8 +1643,6 @@ Cell *printstat(Node **a, int n) /* print a[0] */
|
||||
|
||||
Cell *nullproc(Node **a, int n)
|
||||
{
|
||||
n = n;
|
||||
a = a;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1756,7 +1756,6 @@ Cell *closefile(Node **a, int n)
|
||||
Cell *x;
|
||||
int i, stat;
|
||||
|
||||
n = n;
|
||||
x = execute(a[0]);
|
||||
getsval(x);
|
||||
stat = -1;
|
||||
|
6
tran.c
6
tran.c
@ -347,7 +347,7 @@ char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
|
||||
fldno = atoi(vp->nval);
|
||||
if (fldno > *NF)
|
||||
newfld(fldno);
|
||||
dprintf( ("setting field %d to %s (%p)\n", fldno, s, s) );
|
||||
dprintf( ("setting field %d to %s (%p)\n", fldno, s, (void *) s) );
|
||||
} else if (isrec(vp)) {
|
||||
donefld = 0; /* mark $1... invalid */
|
||||
donerec = 1;
|
||||
@ -363,7 +363,7 @@ char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
|
||||
vp->fmt = NULL;
|
||||
setfree(vp);
|
||||
dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
|
||||
(void*)vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );
|
||||
(void*)vp, NN(vp->nval), t, (void *) t, vp->tval, donerec, donefld) );
|
||||
vp->sval = t;
|
||||
if (&vp->fval == NF) {
|
||||
donerec = 0; /* mark $0 invalid */
|
||||
@ -477,7 +477,7 @@ static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cel
|
||||
}
|
||||
done:
|
||||
dprintf( ("getsval %p: %s = \"%s (%p)\", t=%o\n",
|
||||
(void*)vp, NN(vp->nval), vp->sval, vp->sval, vp->tval) );
|
||||
(void*)vp, NN(vp->nval), vp->sval, (void *) vp->sval, vp->tval) );
|
||||
return(vp->sval);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user