aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2007-10-25 12:38:02 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2007-10-25 12:38:02 +0000
commitd2f6e4922057ff44b13f97a6f641d0aadc21ec1c (patch)
tree4802d08923bb0ee17354898d227a094db941cabf
parentaddad6af5ae5c3a2397dafe2f2c82f556ec25258 (diff)
downloadsrc-d2f6e4922057ff44b13f97a6f641d0aadc21ec1c.tar.gz
src-d2f6e4922057ff44b13f97a6f641d0aadc21ec1c.zip
Vendor import of bwk's 23-Oct-2007 release.
This includes fixes for FreeBSD PR's: bin/104795, bin/100443
Notes
Notes: svn path=/vendor/one-true-awk/dist/; revision=172958
-rw-r--r--contrib/one-true-awk/FIXES8
-rw-r--r--contrib/one-true-awk/lib.c4
-rw-r--r--contrib/one-true-awk/tran.c4
3 files changed, 12 insertions, 4 deletions
diff --git a/contrib/one-true-awk/FIXES b/contrib/one-true-awk/FIXES
index 01a54ef8ce44..2f39d4827c10 100644
--- a/contrib/one-true-awk/FIXES
+++ b/contrib/one-true-awk/FIXES
@@ -25,6 +25,14 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
+Oct 23, 2007:
+ minor fix in lib.c: increase inputFS to 100, change malloc
+ for fields to n+1.
+
+ fixed memory fault caused by out of order test in setsval.
+
+ thanks to david o'brien, freebsd, for both fixes.
+
May 1, 2007:
fiddle in makefile to fix for BSD make; thanks to igor sobrado.
diff --git a/contrib/one-true-awk/lib.c b/contrib/one-true-awk/lib.c
index c3069105ba8d..c9cc5d563b16 100644
--- a/contrib/one-true-awk/lib.c
+++ b/contrib/one-true-awk/lib.c
@@ -40,7 +40,7 @@ char *fields;
int fieldssize = RECSIZE;
Cell **fldtab; /* pointers to Cells */
-char inputFS[10] = " ";
+char inputFS[100] = " ";
#define MAXFLD 2
int nfields = MAXFLD; /* last allocated slot for $i */
@@ -58,7 +58,7 @@ static Cell dollar1 = { OCELL, CFLD, NULL, "", 0.0, FLD|STR|DONTFREE };
void recinit(unsigned int n)
{
if ( (record = (char *) malloc(n)) == NULL
- || (fields = (char *) malloc(n)) == NULL
+ || (fields = (char *) malloc(n+1)) == NULL
|| (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL
|| (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
FATAL("out of space for $0 and fields");
diff --git a/contrib/one-true-awk/tran.c b/contrib/one-true-awk/tran.c
index d8b4a4775c09..c19ce94302a2 100644
--- a/contrib/one-true-awk/tran.c
+++ b/contrib/one-true-awk/tran.c
@@ -332,10 +332,10 @@ char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
donerec = 1;
}
t = tostring(s); /* in case it's self-assign */
- vp->tval &= ~NUM;
- vp->tval |= STR;
if (freeable(vp))
xfree(vp->sval);
+ vp->tval &= ~NUM;
+ vp->tval |= STR;
vp->tval &= ~DONTFREE;
dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );