aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--awkgram.c4
-rw-r--r--awkgram.y4
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in9
-rw-r--r--test/Maketests5
-rw-r--r--test/nulinsrc.awkbin0 -> 3 bytes
-rw-r--r--test/nulinsrc.ok2
9 files changed, 32 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index d2153404..04dbb428 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (nextc): Don't allow '\0' even if check_for_bad
+ is false. Fixes a problem reported by Hanno Boeck <hanno@hboeck.de>.
+
2015-10-16 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (SUBDIRS): Fix ordering so that
diff --git a/awkgram.c b/awkgram.c
index 845dbbef..8e408cac 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -5226,7 +5226,7 @@ again:
0 : work_ring_idx + 1;
cur_char_ring[work_ring_idx] = 0;
}
- if (check_for_bad)
+ if (check_for_bad || *lexptr == '\0')
check_bad_char(*lexptr);
return (int) (unsigned char) *lexptr++;
@@ -5235,7 +5235,7 @@ again:
if (lexeof)
return END_FILE;
if (lexptr && lexptr < lexend) {
- if (check_for_bad)
+ if (check_for_bad || *lexptr == '\0')
check_bad_char(*lexptr);
return ((int) (unsigned char) *lexptr++);
}
diff --git a/awkgram.y b/awkgram.y
index 11771609..2592d13a 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2887,7 +2887,7 @@ again:
0 : work_ring_idx + 1;
cur_char_ring[work_ring_idx] = 0;
}
- if (check_for_bad)
+ if (check_for_bad || *lexptr == '\0')
check_bad_char(*lexptr);
return (int) (unsigned char) *lexptr++;
@@ -2896,7 +2896,7 @@ again:
if (lexeof)
return END_FILE;
if (lexptr && lexptr < lexend) {
- if (check_for_bad)
+ if (check_for_bad || *lexptr == '\0')
check_bad_char(*lexptr);
return ((int) (unsigned char) *lexptr++);
}
diff --git a/test/ChangeLog b/test/ChangeLog
index 6a888496..83174b03 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (nulinsrc): New test.
+ * nulinsrc.awk, nulinsrc.ok: New files.
+
2015-10-26 Arnold D. Robbins <arnold@skeeve.com>
* id.awk: Sort the output. Helps on z/OS.
diff --git a/test/Makefile.am b/test/Makefile.am
index 0d8658a0..97cf8d54 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -627,6 +627,8 @@ EXTRA_DIST = \
noparms.ok \
nors.in \
nors.ok \
+ nulinsrc.awk \
+ nulinsrc.ok \
nulrsend.awk \
nulrsend.in \
nulrsend.ok \
@@ -1040,7 +1042,7 @@ BASIC_TESTS = \
manglprm math membug1 messages minusstr mmap8k mtchi18n \
nasty nasty2 negexp negrange nested nfldstr nfloop nfneg nfset nlfldsep \
nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \
- noparms nors nulrsend numindex numsubstr \
+ noparms nors nulinsrc nulrsend numindex numsubstr \
octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \
paramasfunc1 paramasfunc2 \
paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \
diff --git a/test/Makefile.in b/test/Makefile.in
index 7917fc2d..90b994c3 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -884,6 +884,8 @@ EXTRA_DIST = \
noparms.ok \
nors.in \
nors.ok \
+ nulinsrc.awk \
+ nulinsrc.ok \
nulrsend.awk \
nulrsend.in \
nulrsend.ok \
@@ -1296,7 +1298,7 @@ BASIC_TESTS = \
manglprm math membug1 messages minusstr mmap8k mtchi18n \
nasty nasty2 negexp negrange nested nfldstr nfloop nfneg nfset nlfldsep \
nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \
- noparms nors nulrsend numindex numsubstr \
+ noparms nors nulinsrc nulrsend numindex numsubstr \
octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \
paramasfunc1 paramasfunc2 \
paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \
@@ -3089,6 +3091,11 @@ noparms:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+nulinsrc:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
nulrsend:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 1723c33f..bb5712d5 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -550,6 +550,11 @@ noparms:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+nulinsrc:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
nulrsend:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/nulinsrc.awk b/test/nulinsrc.awk
new file mode 100644
index 00000000..aecda862
--- /dev/null
+++ b/test/nulinsrc.awk
Binary files differ
diff --git a/test/nulinsrc.ok b/test/nulinsrc.ok
new file mode 100644
index 00000000..515f423c
--- /dev/null
+++ b/test/nulinsrc.ok
@@ -0,0 +1,2 @@
+gawk: nulinsrc.awk:1: fatal: PEBKAC error: invalid character '\000' in source code
+EXIT CODE: 2