diff options
author | ru <ru@FreeBSD.org> | 2005-05-16 19:11:36 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2005-05-16 19:11:36 +0000 |
commit | 78d66df18b9755543261f33b621153a97634a136 (patch) | |
tree | 33f1015b814b02b503e72df8a6aea18084ad3991 /contrib/one-true-awk/run.c | |
parent | 90fe2c86f7f5001762e4c3af00a323f801d8b737 (diff) | |
download | FreeBSD-src-78d66df18b9755543261f33b621153a97634a136.zip FreeBSD-src-78d66df18b9755543261f33b621153a97634a136.tar.gz |
Vendor import of bwk's 24-Apr-2005 release.
Diffstat (limited to 'contrib/one-true-awk/run.c')
-rw-r--r-- | contrib/one-true-awk/run.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/contrib/one-true-awk/run.c b/contrib/one-true-awk/run.c index 4648c83..5f29a64 100644 --- a/contrib/one-true-awk/run.c +++ b/contrib/one-true-awk/run.c @@ -26,6 +26,7 @@ THIS SOFTWARE. #include <stdio.h> #include <ctype.h> #include <setjmp.h> +#include <limits.h> #include <math.h> #include <string.h> #include <stdlib.h> @@ -705,12 +706,16 @@ Cell *gettemp(void) /* get a tempcell */ Cell *indirect(Node **a, int n) /* $( a[0] ) */ { + Awkfloat val; Cell *x; int m; char *s; x = execute(a[0]); - m = (int) getfval(x); + val = getfval(x); /* freebsd: defend against super large field numbers */ + if ((Awkfloat)INT_MAX < val) + FATAL("trying to access out of range field %s", x->nval); + m = (int) val; if (m == 0 && !is_number(s = getsval(x))) /* suspicion! */ FATAL("illegal field $(%s), name \"%s\"", s, x->nval); /* BUG: can x->nval ever be null??? */ @@ -1257,6 +1262,8 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ goto spdone; } } while (nematch(pfa,s)); + pfa->initstat = tempstat; /* bwk: has to be here to reset */ + /* cf gsub and refldbld */ } n++; sprintf(num, "%d", n); |