summaryrefslogtreecommitdiff
path: root/regress/usr.bin
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2014-12-07 14:32:35 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2014-12-07 14:32:35 +0000
commit0f91aea7d238a025044263259bb77a7b15fbb099 (patch)
tree5a47bf0879a39db8b98af23f7d170a36ed20f434 /regress/usr.bin
parent906361195dae243136901fdff47328b5d3ff9408 (diff)
Add a test for redefining a macro name in the expansion of
the macro with the same name. This often causes m4 to crash with malloc.conf F/Freeguard though not reliably. Crash found with the afl fuzzer.
Diffstat (limited to 'regress/usr.bin')
-rw-r--r--regress/usr.bin/m4/Makefile7
-rw-r--r--regress/usr.bin/m4/redef2.m46
2 files changed, 11 insertions, 2 deletions
diff --git a/regress/usr.bin/m4/Makefile b/regress/usr.bin/m4/Makefile
index 59170bc0a88..81446f19998 100644
--- a/regress/usr.bin/m4/Makefile
+++ b/regress/usr.bin/m4/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.30 2012/04/12 16:58:15 espie Exp $
+# $OpenBSD: Makefile,v 1.31 2014/12/07 14:32:34 jsg Exp $
FIBOMAX=25
M4=m4
@@ -8,7 +8,7 @@ CLEANFILES+= ff_after_dnl.m4 strangequotes.m4 fibo.out
REGRESS_TARGETS= test-ff_after_dnl test-m4wrap test-m4wrap2 \
test-m4wrap3 test-gm4wrap3 test-fibo \
- test-patterns trip test-strangequotes test-redef test-quotes \
+ test-patterns trip test-strangequotes test-redef test-redef2 test-quotes \
test-weird test-args test-args2 test-esyscmd test-eval test-gnupatterns \
test-gnupatterns2 test-comments test-synch1 test-synch1bis \
test-gnuformat test-includes test-dumpdef test-gnuprefix \
@@ -70,6 +70,9 @@ test-strangequotes: strangequotes.m4
test-redef:
${M4} ${.CURDIR}/redef.m4 | diff - ${.CURDIR}/redef.out
+test-redef2:
+ MALLOC_OPTIONS=F ${M4} ${.CURDIR}/redef2.m4 2>/dev/null
+
test-weird:
test `${M4} ${.CURDIR}/weird,name.m4 | wc -c` == 0
diff --git a/regress/usr.bin/m4/redef2.m4 b/regress/usr.bin/m4/redef2.m4
new file mode 100644
index 00000000000..caff6cee224
--- /dev/null
+++ b/regress/usr.bin/m4/redef2.m4
@@ -0,0 +1,6 @@
+dnl $OpenBSD: redef2.m4,v 1.1 2014/12/07 14:32:34 jsg Exp $
+dnl recursive macro redefinition
+define(`A', `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
+A(
+ define(`A', `bbbbbbbbbbbbbbbbbbb')
+)