diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | awkgram.c | 9 | ||||
-rw-r--r-- | awkgram.y | 9 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 10 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/readbuf.awk | 2 | ||||
-rw-r--r-- | test/readbuf.ok | 3 |
9 files changed, 45 insertions, 8 deletions
@@ -1,3 +1,8 @@ +2015-10-11 Arnold D. Robbins <arnold@skeeve.com> + + * awkgram.y (yylex): Fix invalid read problems. + Reported by Hanno Boeck <hanno@hboeck.de>. + 2015-10-04 Arnold D. Robbins <arnold@skeeve.com> * configure.ac: Bump version to 4.1.3a. @@ -149,8 +149,8 @@ const char *const ruletab[] = { static bool in_print = false; /* lexical scanning kludge for print */ static int in_parens = 0; /* lexical scanning kludge for print */ static int sub_counter = 0; /* array dimension counter for use in delete */ -static char *lexptr = NULL; /* pointer to next char during parsing */ -static char *lexend; +static char *lexptr; /* pointer to next char during parsing */ +static char *lexend; /* end of buffer */ static char *lexptr_begin; /* keep track of where we were for error msgs */ static char *lexeme; /* beginning of lexeme for debugging */ static bool lexeof; /* seen EOF for current source? */ @@ -4706,7 +4706,8 @@ yyerror(const char *m, ...) if (thisline == NULL) { cp = lexeme; if (*cp == '\n') { - cp--; + if (cp > lexptr_begin) + cp--; mesg = _("unexpected newline or end of string"); } for (; cp != lexptr_begin && *cp != '\n'; --cp) @@ -4717,6 +4718,8 @@ yyerror(const char *m, ...) } /* NL isn't guaranteed */ bp = lexeme; + if (bp < thisline) + bp = thisline + 1; while (bp < lexend && *bp && *bp != '\n') bp++; } else { @@ -109,8 +109,8 @@ const char *const ruletab[] = { static bool in_print = false; /* lexical scanning kludge for print */ static int in_parens = 0; /* lexical scanning kludge for print */ static int sub_counter = 0; /* array dimension counter for use in delete */ -static char *lexptr = NULL; /* pointer to next char during parsing */ -static char *lexend; +static char *lexptr; /* pointer to next char during parsing */ +static char *lexend; /* end of buffer */ static char *lexptr_begin; /* keep track of where we were for error msgs */ static char *lexeme; /* beginning of lexeme for debugging */ static bool lexeof; /* seen EOF for current source? */ @@ -2286,7 +2286,8 @@ yyerror(const char *m, ...) if (thisline == NULL) { cp = lexeme; if (*cp == '\n') { - cp--; + if (cp > lexptr_begin) + cp--; mesg = _("unexpected newline or end of string"); } for (; cp != lexptr_begin && *cp != '\n'; --cp) @@ -2297,6 +2298,8 @@ yyerror(const char *m, ...) } /* NL isn't guaranteed */ bp = lexeme; + if (bp < thisline) + bp = thisline + 1; while (bp < lexend && *bp && *bp != '\n') bp++; } else { diff --git a/test/ChangeLog b/test/ChangeLog index d6cbb95c..6312e21d 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2015-10-11 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (readbuf): New test. + * readbuf.awk, readbuf.ok: New files. + 2015-09-26 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (muldimposix): New test. diff --git a/test/Makefile.am b/test/Makefile.am index e6c623f7..5fda72a1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -786,6 +786,8 @@ EXTRA_DIST = \ range1.awk \ range1.in \ range1.ok \ + readbuf.awk \ + readbuf.ok \ readdir.awk \ readdir0.awk \ readfile2.awk \ @@ -1088,7 +1090,8 @@ BASIC_TESTS = \ paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \ pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ prt1eval prtoeval \ - rand randtest range1 rebrackloc rebt8b1 redfilnm regeq regexpbrack regexpbrack2 \ + rand randtest range1 readbuf rebrackloc rebt8b1 redfilnm \ + regeq regexpbrack regexpbrack2 \ regexprange regrange reindops \ reparse resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ rstest3 rstest4 rstest5 rswhite \ diff --git a/test/Makefile.in b/test/Makefile.in index 1cced4ac..dc1b3cad 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1043,6 +1043,8 @@ EXTRA_DIST = \ range1.awk \ range1.in \ range1.ok \ + readbuf.awk \ + readbuf.ok \ readdir.awk \ readdir0.awk \ readfile2.awk \ @@ -1344,7 +1346,8 @@ BASIC_TESTS = \ paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \ pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ prt1eval prtoeval \ - rand randtest range1 rebrackloc rebt8b1 redfilnm regeq regexpbrack regexpbrack2 \ + rand randtest range1 readbuf rebrackloc rebt8b1 redfilnm \ + regeq regexpbrack regexpbrack2 \ regexprange regrange reindops \ reparse resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ rstest3 rstest4 rstest5 rswhite \ @@ -3322,6 +3325,11 @@ range1: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +readbuf: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + rebrackloc: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index cc00b085..3035b0c6 100644 --- a/test/Maketests +++ b/test/Maketests @@ -702,6 +702,11 @@ range1: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +readbuf: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + rebrackloc: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/readbuf.awk b/test/readbuf.awk new file mode 100644 index 00000000..b7512db4 --- /dev/null +++ b/test/readbuf.awk @@ -0,0 +1,2 @@ + +{ diff --git a/test/readbuf.ok b/test/readbuf.ok new file mode 100644 index 00000000..110a26bc --- /dev/null +++ b/test/readbuf.ok @@ -0,0 +1,3 @@ +gawk: readbuf.awk:2: { +gawk: readbuf.awk:2: ^ unexpected newline or end of string +EXIT CODE: 1 |