When a mismatching end macro occurs while at least two nested blocks
authorschwarze <schwarze@openbsd.org>
Sat, 20 Aug 2016 17:58:09 +0000 (17:58 +0000)
committerschwarze <schwarze@openbsd.org>
Sat, 20 Aug 2016 17:58:09 +0000 (17:58 +0000)
commitf4269c9f5eb96ceb250e223c7e073a0650c3b439
tree3633bb0ffe94a2acae48778fbe6558a1b2566c44
parent57104dfd43a6bc418b81126b899a74a4877ef3c3
When a mismatching end macro occurs while at least two nested blocks
are open, all except the innermost open block got a bogus MDOC_ENDED
marker, in some situations triggering segfaults down the road
which tb@ found with afl(1).
Fix the logic error by figuring out up front whether an end macro
has a matching body, and if it hasn't, don't mark any blocks as broken.
regress/usr.bin/mandoc/mdoc/break/Makefile
regress/usr.bin/mandoc/mdoc/break/notopen.in [new file with mode: 0644]
regress/usr.bin/mandoc/mdoc/break/notopen.out_ascii [new file with mode: 0644]
regress/usr.bin/mandoc/mdoc/break/notopen.out_lint [new file with mode: 0644]
usr.bin/mandoc/mdoc_macro.c