diff options
author | Sheldon Hearn <sheldonh@FreeBSD.org> | 2000-09-04 10:42:19 +0000 |
---|---|---|
committer | Sheldon Hearn <sheldonh@FreeBSD.org> | 2000-09-04 10:42:19 +0000 |
commit | c3f4a674940e6e6463789717fb354dcc04f3a2cd (patch) | |
tree | 55d267ef4ea8547ed788d04a114dc6a6a6487865 | |
parent | 5f435a0876282d2ef9c6bdac210d923072b63a91 (diff) | |
download | src-c3f4a674940e6e6463789717fb354dcc04f3a2cd.tar.gz src-c3f4a674940e6e6463789717fb354dcc04f3a2cd.zip |
Fix bug that causes gawk to choke when parsing long source files.
Reported by: Tony Fleisher <takhus@takhus.mind.net>
Submitted by: Aharon Robbins <arnold@skeeve.com>
Notes
Notes:
svn path=/head/; revision=65435
-rw-r--r-- | contrib/awk/builtin.c | 6 | ||||
-rw-r--r-- | contrib/awk/field.c | 10 |
2 files changed, 11 insertions, 5 deletions
diff --git a/contrib/awk/builtin.c b/contrib/awk/builtin.c index 89babb35193c..fc9365b229c3 100644 --- a/contrib/awk/builtin.c +++ b/contrib/awk/builtin.c @@ -2104,9 +2104,11 @@ size_t len; retval = (retval * 16) + val; } } else if (*str == '0') { + if (strchr(str, '8') != NULL || strchr(str, '9') != NULL) + goto decimal; for (; len > 0; len--) { - if (! isdigit(*str) || *str == '8' || *str == '9') - goto decimal; + if (! isdigit(*str)) + goto done; retval = (retval * 8) + (*str - '0'); str++; } diff --git a/contrib/awk/field.c b/contrib/awk/field.c index bd038a0609a1..097196e36bfa 100644 --- a/contrib/awk/field.c +++ b/contrib/awk/field.c @@ -264,9 +264,13 @@ int freeold; emalloc(databuf, char *, INITIAL_SIZE, "set_record"); databuf_size = INITIAL_SIZE; } - /* make sure there's enough room */ - if (cnt > databuf_size) { - while (cnt > databuf_size && databuf_size <= MAX_SIZE) + /* + * Make sure there's enough room. Since we sometimes need + * to place a sentinel at the end, we make sure + * databuf_size is > cnt after allocation. + */ + if (cnt >= databuf_size) { + while (cnt >= databuf_size && databuf_size <= MAX_SIZE) databuf_size *= 2; erealloc(databuf, char *, databuf_size, "set_record"); } |