summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-08-19 17:28:57 +0000
committerschwarze <schwarze@openbsd.org>2014-08-19 17:28:57 +0000
commitdadc3a61401b8f8bb2df584ab32d18a799c7f0ec (patch)
tree775c3551a867f2e31399d02124c6879c24df66a4
parentSimplify some checks (diff)
downloadwireguard-openbsd-dadc3a61401b8f8bb2df584ab32d18a799c7f0ec.tar.xz
wireguard-openbsd-dadc3a61401b8f8bb2df584ab32d18a799c7f0ec.zip
Do not dereference a NULL pointer if a .Bl macro has
no -type, -width, -offset or -compact arguments whatsoever; this got broken in mdoc_validate.c rev. 1.156. While here, sort headers.
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/notype.in12
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii10
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint3
-rw-r--r--usr.bin/mandoc/mdoc_validate.c8
4 files changed, 24 insertions, 9 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/notype.in b/regress/usr.bin/mandoc/mdoc/Bl/notype.in
index d28a5b0d82f..dce46bf80ba 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/notype.in
+++ b/regress/usr.bin/mandoc/mdoc/Bl/notype.in
@@ -5,14 +5,22 @@
.Nm Bl-notype
.Nd lists with late or missing types
.Sh DESCRIPTION
-initial text
+late type:
.Bl -offset indent -bullet
.It
Some text.
.El tail argument
-middle text
+.Pp
+no type:
.Bl -offset indent
.It
Some text.
.El
+.Pp
+no argument at all:
+.Bl
+.It
+Some text.
+.El
+.Pp
final text
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii
index 02a9960338a..2bb4d069f56 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii
@@ -4,12 +4,18 @@ NNAAMMEE
BBll--nnoottyyppee - lists with late or missing types
DDEESSCCRRIIPPTTIIOONN
- initial text
+ late type:
oo Some text.
- middle text
+
+ no type:
Some text.
+
+ no argument at all:
+
+ Some text.
+
final text
OpenBSD July 4, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint
index ec90ae56602..c14bd0b46be 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint
@@ -1,3 +1,4 @@
mandoc: notype.in:9:2: WARNING: list type is not the first argument: Bl -offset
mandoc: notype.in:12:2: ERROR: skipping all arguments: El tail argument
-mandoc: notype.in:14:2: ERROR: missing list type, using -item: Bl
+mandoc: notype.in:15:2: ERROR: missing list type, using -item: Bl
+mandoc: notype.in:21:2: ERROR: missing list type, using -item: Bl
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index fcca5e06f0a..0612989d5db 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.161 2014/08/08 16:17:09 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.162 2014/08/19 17:28:57 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -16,12 +16,12 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+
+#include <sys/types.h>
#ifndef OSNAME
#include <sys/utsname.h>
#endif
-#include <sys/types.h>
-
#include <assert.h>
#include <ctype.h>
#include <limits.h>
@@ -528,7 +528,7 @@ pre_bl(PRE_ARGS)
* ones. If we find no list type, we default to LIST_item.
*/
- wa = n->args->argv;
+ wa = (n->args == NULL) ? NULL : n->args->argv;
mdoclt = MDOC_ARG_MAX;
for (i = 0; n->args && i < (int)n->args->argc; i++) {
argv = n->args->argv + i;