diff options
author | 2015-02-02 04:04:18 +0000 | |
---|---|---|
committer | 2015-02-02 04:04:18 +0000 | |
commit | c5ac3e88fb468f04cea456120d7d8d5008f7affd (patch) | |
tree | 51ca3779ecf991b7aa0af50c187813a633e5e6c0 | |
parent | increasing encounters with difficult DNS setups in darknets has (diff) | |
download | wireguard-openbsd-c5ac3e88fb468f04cea456120d7d8d5008f7affd.tar.xz wireguard-openbsd-c5ac3e88fb468f04cea456120d7d8d5008f7affd.zip |
When a full block macro gets closed out by a mismatching
block closure macro it calls, do not attempt to open its body.
This can for example happen for (nonsensical) constructions like
.Fo
.Nm Fc
in the SYNOPSIS. Fixing an assertion failure jsg@ found with afl
some time ago (test case number 731).
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Nm/Makefile | 21 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Nm/broken.in | 10 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Nm/broken.out_ascii | 11 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 11 |
4 files changed, 41 insertions, 12 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Nm/Makefile b/regress/usr.bin/mandoc/mdoc/Nm/Makefile index 46ef3db412a..d575de0285a 100644 --- a/regress/usr.bin/mandoc/mdoc/Nm/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Nm/Makefile @@ -1,18 +1,23 @@ -# $OpenBSD: Makefile,v 1.10 2014/08/21 12:56:24 schwarze Exp $ +# $OpenBSD: Makefile,v 1.11 2015/02/02 04:04:18 schwarze Exp $ -REGRESS_TARGETS = badNAME badNAMEuse break empty emptyNAME emptyNAMEuse +REGRESS_TARGETS = badNAME badNAMEuse break broken +REGRESS_TARGETS += empty emptyNAME emptyNAMEuse REGRESS_TARGETS += font long punct LINT_TARGETS = badNAME badNAMEuse break -# groff-1.22.2/mandoc difference: -# When the first Nm does not have an argument but a later one has, -# mandoc retroactively uses the later name for the earlier instances -# of Nm, too, while groff does not. +# groff-1.22.3/mandoc differences: +# - When the first Nm does not have an argument but a later one has, +# mandoc retroactively uses the later name for the earlier instances +# of Nm, too, while groff does not. +# - When the head of an Nm block in the SYNOPSIS is broken by an +# explicit block end macro on the same line, formatting differs, +# but doesn't make sense either way. -SKIP_GROFF = badNAMEuse emptyNAMEuse +SKIP_GROFF = badNAMEuse emptyNAMEuse broken +SKIP_TMAN = broken SILENT -# groff-1.22.2 defect: +# groff-1.22.3 defect: # When a SYNOPSIS Nm block head breaks a sub block, all the # remaining content in the document gets lost. diff --git a/regress/usr.bin/mandoc/mdoc/Nm/broken.in b/regress/usr.bin/mandoc/mdoc/Nm/broken.in new file mode 100644 index 00000000000..58a28bad85d --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Nm/broken.in @@ -0,0 +1,10 @@ +.Dd February 2, 2015 +.Dt NM-BROKEN 1 +.Os OpenBSD +.Sh NAME +.Nm Nm-broken +.Nd broken synapsis name block +.Sh SYNOPSIS +.Ft int +.Fo function +.Nm name Fc tail diff --git a/regress/usr.bin/mandoc/mdoc/Nm/broken.out_ascii b/regress/usr.bin/mandoc/mdoc/Nm/broken.out_ascii new file mode 100644 index 00000000000..1f9ed5a29be --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Nm/broken.out_ascii @@ -0,0 +1,11 @@ +NM-BROKEN(1) General Commands Manual NM-BROKEN(1) + +NNAAMMEE + NNmm--bbrrookkeenn - broken synapsis name block + +SSYYNNOOPPSSIISS + _i_n_t + ffuunnccttiioonn(nnaammee); + tail + +OpenBSD February 2, 2015 OpenBSD diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 9c152ea9158..1ec2d8038e3 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.120 2015/02/01 23:55:37 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.121 2015/02/02 04:04:18 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -1075,8 +1075,9 @@ blk_full(MACRO_PROT_ARGS) { int la, nl, parsed; struct mdoc_arg *arg; - struct mdoc_node *head; /* save of head macro */ - struct mdoc_node *body; /* save of body macro */ + struct mdoc_node *blk; /* Our own block. */ + struct mdoc_node *head; /* Our own head. */ + struct mdoc_node *body; /* Our own body. */ struct mdoc_node *n; enum margserr ac, lac; char *p; @@ -1116,7 +1117,7 @@ blk_full(MACRO_PROT_ARGS) */ mdoc_argv(mdoc, line, tok, &arg, pos, buf); - mdoc_block_alloc(mdoc, line, ppos, tok, arg); + blk = mdoc_block_alloc(mdoc, line, ppos, tok, arg); head = body = NULL; /* @@ -1216,6 +1217,8 @@ blk_full(MACRO_PROT_ARGS) break; } + if (blk->flags & MDOC_VALID) + return; if (head == NULL) head = mdoc_head_alloc(mdoc, line, ppos, tok); if (nl) |