source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Element next-line scopes can nest.
@ 2020-09-09 17:01 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2020-09-09 17:01 UTC (permalink / raw)
  To: source

Log Message:
-----------
Element next-line scopes can nest.  Consequently, even when closing
one element next-line scope, the MAN_ELINE flag must not yet be
cleared if the parent macro is another element macro having next-line
scope, or an assertion failure is caused if all this is wrapped in
another macro that has block next-line scope, for example .TP.
Bug found in an afl run performed by Jan Schreiber <jes at posteo dot de>.

Modified Files:
--------------
    mandoc:
        man_macro.c
    mandoc/regress/man/TP:
        broken.in
        broken.out_ascii
        broken.out_lint
        macrotag.in
        macrotag.out_ascii

Revision Data
-------------
Index: man_macro.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_macro.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -Lman_macro.c -Lman_macro.c -u -p -r1.144 -r1.145
--- man_macro.c
+++ man_macro.c
@@ -1,7 +1,7 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -107,9 +107,11 @@ man_unscope(struct roff_man *man, const 
 				mandoc_msg(MANDOCERR_BLK_LINE,
 				    n->line, n->pos,
 				    "EOF breaks %s", roff_name[n->tok]);
-				if (man->flags & MAN_ELINE)
-					man->flags &= ~MAN_ELINE;
-				else {
+				if (man->flags & MAN_ELINE) {
+					if ((man_macro(n->parent->tok)->flags &
+					    MAN_ESCOPED) == 0)
+						man->flags &= ~MAN_ELINE;
+				} else {
 					assert(n->type == ROFFT_HEAD);
 					n = n->parent;
 					man->flags &= ~MAN_BLINE;
Index: broken.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/TP/broken.out_ascii,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/man/TP/broken.out_ascii -Lregress/man/TP/broken.out_ascii -u -p -r1.2 -r1.3
--- regress/man/TP/broken.out_ascii
+++ regress/man/TP/broken.out_ascii
@@ -3,7 +3,7 @@ TP-BROKEN(1)                General Comm
 
 
 N\bNA\bAM\bME\bE
-       TP-broken - broken tagged paragraph
+       TP-broken - broken tagged paragraphs
 
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
        regular text
@@ -14,4 +14,4 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
 
 
 
-OpenBSD                        December 16, 2014                  TP-BROKEN(1)
+OpenBSD                        September 9, 2020                  TP-BROKEN(1)
Index: macrotag.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/TP/macrotag.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/man/TP/macrotag.in -Lregress/man/TP/macrotag.in -u -p -r1.2 -r1.3
--- regress/man/TP/macrotag.in
+++ regress/man/TP/macrotag.in
@@ -1,12 +1,24 @@
-.\" $OpenBSD: macrotag.in,v 1.3 2017/07/04 14:53:24 schwarze Exp $
-.TH TP-MACROTAG 1 "September 20, 2011"
+.\" $OpenBSD: macrotag.in,v 1.4 2020/09/09 16:57:05 schwarze Exp $
+.TH TP-MACROTAG 1 "September 9, 2020"
 .SH NAME
-TP-macrotag \- macro in the head of a tagged paragraph
+TP-macrotag \- macros in the head of tagged paragraphs
 .SH DESCRIPTION
 regular
 text
 .TP
 .B longindent
+indented
+text
+.TP
+.B
+.I
+next-line
+indented
+text
+.TP
+.B
+.SM
+bold small
 indented
 text
 .PP
Index: macrotag.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/TP/macrotag.out_ascii,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/man/TP/macrotag.out_ascii -Lregress/man/TP/macrotag.out_ascii -u -p -r1.1 -r1.2
--- regress/man/TP/macrotag.out_ascii
+++ regress/man/TP/macrotag.out_ascii
@@ -3,7 +3,7 @@ TP-MACROTAG(1)              General Comm
 
 
 N\bNA\bAM\bME\bE
-       TP-macrotag - macro in the head of a tagged paragraph
+       TP-macrotag - macros in the head of tagged paragraphs
 
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
        regular text
@@ -11,8 +11,14 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
        l\blo\bon\bng\bgi\bin\bnd\bde\ben\bnt\bt
               indented text
 
+       _\bn_\be_\bx_\bt_\b-_\bl_\bi_\bn_\be
+              indented text
+
+       b\bbo\bol\bld\bd s\bsm\bma\bal\bll\bl
+              indented text
+
        regular text
 
 
 
-OpenBSD                       September 20, 2011                TP-MACROTAG(1)
+OpenBSD                        September 9, 2020                TP-MACROTAG(1)
Index: broken.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/TP/broken.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lregress/man/TP/broken.in -Lregress/man/TP/broken.in -u -p -r1.3 -r1.4
--- regress/man/TP/broken.in
+++ regress/man/TP/broken.in
@@ -1,7 +1,7 @@
-.\" $OpenBSD: broken.in,v 1.3 2017/07/04 14:53:24 schwarze Exp $
-.TH TP-BROKEN 1 "December 16, 2014"
+.\" $OpenBSD: broken.in,v 1.4 2020/09/09 16:57:05 schwarze Exp $
+.TH TP-BROKEN 1 "September 9, 2020"
 .SH NAME
-TP-broken \- broken tagged paragraph
+TP-broken \- broken tagged paragraphs
 .SH DESCRIPTION
 regular
 text
@@ -16,3 +16,6 @@ text
 
 head
 body
+.TP
+.B
+.I
Index: broken.out_lint
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/man/TP/broken.out_lint,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lregress/man/TP/broken.out_lint -Lregress/man/TP/broken.out_lint -u -p -r1.5 -r1.6
--- regress/man/TP/broken.out_lint
+++ regress/man/TP/broken.out_lint
@@ -1,2 +1,5 @@
 mandoc: broken.in:11:2: WARNING: line scope broken: RE breaks TP
 mandoc: broken.in:16:1: WARNING: skipping blank line in line scope
+mandoc: broken.in:21:2: WARNING: line scope broken: EOF breaks I
+mandoc: broken.in:20:2: WARNING: line scope broken: EOF breaks B
+mandoc: broken.in:19:2: WARNING: line scope broken: EOF breaks TP
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-09 17:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 17:01 mandoc: Element next-line scopes can nest schwarze

source@mandoc.bsd.lv

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/mandoc-source

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 mandoc-source mandoc-source/ http://inbox.vuxu.org/mandoc-source \
		source@mandoc.bsd.lv
	public-inbox-index mandoc-source

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git