diff options
author | 2015-10-30 19:03:36 +0000 | |
---|---|---|
committer | 2015-10-30 19:03:36 +0000 | |
commit | a43e24e288346bc8f4a342f315c71e3e06d3c1e0 (patch) | |
tree | 752110eb755715d06f1556658c106f0e8832109d | |
parent | Do not access a NULL pointer when a .Bd macro has no arguments at all. (diff) | |
download | wireguard-openbsd-a43e24e288346bc8f4a342f315c71e3e06d3c1e0.tar.xz wireguard-openbsd-a43e24e288346bc8f4a342f315c71e3e06d3c1e0.zip |
If a .Bd block has no arguments at all, drop the block and only keep
its contents. Removing a gratuitious difference to groff output
found after a related bug report from krw@.
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bd/badargs.in | 7 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii | 3 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.1 | 11 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 12 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 3 |
8 files changed, 37 insertions, 10 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Bd/badargs.in b/regress/usr.bin/mandoc/mdoc/Bd/badargs.in index 4b06a528776..0d8b3f4d647 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/badargs.in +++ b/regress/usr.bin/mandoc/mdoc/Bd/badargs.in @@ -1,4 +1,4 @@ -.Dd July 5, 2014 +.Dd October 27, 2015 .Dt BD-BADARGS 1 .Os OpenBSD .Sh NAME @@ -44,3 +44,8 @@ missing -file argument: ragged offset indent .Ed +no argument whatsoever: +.Bd +no +argument +.Ed diff --git a/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii b/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii index 8cfd38e5f58..1a123a6cafa 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii @@ -25,5 +25,6 @@ DDEESSCCRRIIPPTTIIOONN missing -file argument: ragged offset indent + no argument whatsoever: no argument -OpenBSD July 5, 2014 OpenBSD +OpenBSD October 27, 2015 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint b/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint index 554577d4062..10c9cb021dd 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint @@ -1,11 +1,12 @@ -mandoc: badargs.in:9:13: WARNING: empty argument, using 0n: Bd -offset mandoc: badargs.in:12:2: ERROR: skipping all arguments: Ed tail argument +mandoc: badargs.in:19:16: ERROR: skipping excess arguments: Bd ... -bogus +mandoc: badargs.in:9:13: WARNING: empty argument, using 0n: Bd -offset mandoc: badargs.in:14:34: WARNING: duplicate argument: Bd -compact mandoc: badargs.in:14:43: WARNING: duplicate argument: Bd -offset 6n mandoc: badargs.in:19:2: WARNING: missing display type, using -ragged: Bd -mandoc: badargs.in:19:16: ERROR: skipping excess arguments: Bd ... -bogus mandoc: badargs.in:24:2: WARNING: skipping duplicate display type: Bd -unfilled mandoc: badargs.in:28:2: WARNING: skipping duplicate display type: Bd -ragged mandoc: badargs.in:33:2: ERROR: NOT IMPLEMENTED: Bd -file mandoc: badargs.in:38:2: ERROR: NOT IMPLEMENTED: Bd -file mandoc: badargs.in:43:2: ERROR: NOT IMPLEMENTED: Bd -file +mandoc: badargs.in:48:2: ERROR: skipping display without arguments: Bd diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index 39a66a81283..3500983b2e4 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mandoc.1,v 1.86 2015/09/26 17:12:45 jmc Exp $ +.\" $OpenBSD: mandoc.1,v 1.87 2015/10/30 19:03:36 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 26 2015 $ +.Dd $Mdocdate: October 30 2015 $ .Dt MANDOC 1 .Os .Sh NAME @@ -1600,6 +1600,13 @@ By requesting the inclusion of a sensitive file, a malicious document might otherwise trick a privileged user into inadvertently displaying the file on the screen, revealing the file content to bystanders. The argument is ignored including the file name following it. +.It Sy "skipping display without arguments" +.Pq mdoc +A +.Ic \&Bd +block macro does not have any arguments. +The block is discarded, and the block content is displayed in +whatever mode was active before the block. .It Sy "missing list type, using -item" .Pq mdoc A diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index 25490fd8ebd..0aecdb0ce4d 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.148 2015/10/13 22:57:49 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.149 2015/10/30 19:03:36 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -172,6 +172,7 @@ enum mandocerr { /* related to request and macro arguments */ MANDOCERR_NAMESC, /* escaped character not allowed in a name: name */ MANDOCERR_BD_FILE, /* NOT IMPLEMENTED: Bd -file */ + MANDOCERR_BD_NOARG, /* skipping display without arguments: Bd */ MANDOCERR_BL_NOTYPE, /* missing list type, using -item: Bl */ MANDOCERR_NM_NONAME, /* missing manual name, using "": Nm */ MANDOCERR_OS_UNAME, /* uname(3) system call failed, using UNKNOWN */ diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index 0a84263dcb5..56ae0c9acd5 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc.c,v 1.144 2015/10/20 02:00:49 schwarze Exp $ */ +/* $OpenBSD: mdoc.c,v 1.145 2015/10/30 19:03:36 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -203,6 +203,7 @@ mdoc_node_relink(struct roff_man *mdoc, struct roff_node *p) { roff_node_unlink(mdoc, p); + p->prev = p->next = NULL; roff_node_append(mdoc, p); } diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index b5f8fcebdb0..5c65594b432 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.215 2015/10/21 23:49:05 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.216 2015/10/30 19:03:36 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -886,6 +886,16 @@ post_display(POST_ARGS) break; case ROFFT_BLOCK: if (n->tok == MDOC_Bd) { + if (n->args == NULL) { + mandoc_msg(MANDOCERR_BD_NOARG, + mdoc->parse, n->line, n->pos, "Bd"); + mdoc->next = ROFF_NEXT_SIBLING; + while (n->body->child != NULL) + mdoc_node_relink(mdoc, + n->body->child); + roff_node_delete(mdoc, n); + break; + } post_bd(mdoc); post_prevpar(mdoc); } diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 830c73ef2c6..c5c7da6f65b 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.119 2015/10/13 22:57:49 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.120 2015/10/30 19:03:36 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -210,6 +210,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { /* related to request and macro arguments */ "escaped character not allowed in a name", "NOT IMPLEMENTED: Bd -file", + "skipping display without arguments", "missing list type, using -item", "missing manual name, using \"\"", "uname(3) system call failed, using UNKNOWN", |