From 57104dfd43a6bc418b81126b899a74a4877ef3c3 Mon Sep 17 00:00:00 2001 From: schwarze Date: Sat, 20 Aug 2016 15:58:16 +0000 Subject: [PATCH] When scanning upwards for a column list to put a .Ta macro in, ignore body end markers of lists breaking other blocks. Fixing a logical error that caused a NULL deref found by tb@ with afl(1). --- regress/usr.bin/mandoc/mdoc/Bl/break.in | 12 +++++++++++- regress/usr.bin/mandoc/mdoc/Bl/break.out_ascii | 9 ++++++++- regress/usr.bin/mandoc/mdoc/Bl/break.out_lint | 16 +++++++++------- usr.bin/mandoc/mdoc_macro.c | 4 ++-- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/regress/usr.bin/mandoc/mdoc/Bl/break.in b/regress/usr.bin/mandoc/mdoc/Bl/break.in index 03a85364bc4..3246fdc72ec 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/break.in +++ b/regress/usr.bin/mandoc/mdoc/Bl/break.in @@ -1,4 +1,4 @@ -.Dd December 18, 2014 +.Dd August 20, 2016 .Dt BL-BREAK 1 .Os OpenBSD .Sh NAME @@ -55,6 +55,16 @@ first line after table second line after table .El after list +.Sh DIAGNOSTICS +.Bl -column column +.It column +.Bd -ragged -offset indent +inside display +.El +.Ta stray tab +after stray tab +.Ed +after display .Sh CAVEATS .Bl -hang .It before broken block Bo inside both diff --git a/regress/usr.bin/mandoc/mdoc/Bl/break.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/break.out_ascii index 30a6888b559..692711c4075 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/break.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bl/break.out_ascii @@ -33,10 +33,17 @@ EEXXAAMMPPLLEESS table after list +DDIIAAGGNNOOSSTTIICCSS + column + + inside display after stray tab + + after display + CCAAVVEEAATTSS before broken block [inside both after list] BBUUGGSS 1. -OpenBSD December 18, 2014 OpenBSD +OpenBSD August 20, 2016 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Bl/break.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/break.out_lint index 934b4c1dc11..fe099a470b0 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/break.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bl/break.out_lint @@ -7,10 +7,12 @@ mandoc: break.in:42:2: ERROR: skipping item outside list: It mandoc: break.in:53:2: WARNING: blocks badly nested: Bl breaks Bd mandoc: break.in:56:2: WARNING: blocks badly nested: Bl breaks Bd mandoc: break.in:58:2: ERROR: inserting missing end of block: Sh breaks Bd -mandoc: break.in:61:2: WARNING: blocks badly nested: Bl breaks Bo -mandoc: break.in:63:2: ERROR: inserting missing end of block: Sh breaks Bo -mandoc: break.in:66:2: WARNING: blocks badly nested: Bl breaks Bo -mandoc: break.in:65:25: ERROR: appending missing end of block: Bo -mandoc: break.in:64:2: ERROR: appending missing end of block: Bl -mandoc: break.in:65:2: WARNING: empty list item: Bl -enum It -mandoc: break.in:65:2: ERROR: skipping all arguments: It before broken block +mandoc: break.in:63:2: WARNING: blocks badly nested: Bl breaks Bd +mandoc: break.in:64:2: ERROR: skipping column outside column list: Ta +mandoc: break.in:71:2: WARNING: blocks badly nested: Bl breaks Bo +mandoc: break.in:73:2: ERROR: inserting missing end of block: Sh breaks Bo +mandoc: break.in:76:2: WARNING: blocks badly nested: Bl breaks Bo +mandoc: break.in:75:25: ERROR: appending missing end of block: Bo +mandoc: break.in:74:2: ERROR: appending missing end of block: Bl +mandoc: break.in:75:2: WARNING: empty list item: Bl -enum It +mandoc: break.in:75:2: ERROR: skipping all arguments: It before broken block diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 7bc6b7057b4..331aeb52903 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.163 2016/08/13 09:14:56 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.164 2016/08/20 15:58:16 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012-2015 Ingo Schwarze @@ -1457,7 +1457,7 @@ phrase_ta(MACRO_PROT_ARGS) continue; if (n->tok == MDOC_It && n->type == ROFFT_BODY) body = n; - if (n->tok == MDOC_Bl) + if (n->tok == MDOC_Bl && n->end == ENDBODY_NOT) break; } -- 2.20.1