aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-09-12 18:21:03 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-09-12 18:21:03 +0000
commitde25e57757f7ad49514c641e9a5af4f925f5ebfe (patch)
treec2bae97690ed0d094937752c11bbed50d7e61de5
parent48353a6c8ecdceade028d1fa25f5f0ba490fe536 (diff)
downloadmandoc-de25e57757f7ad49514c641e9a5af4f925f5ebfe.tar.gz
mandoc-de25e57757f7ad49514c641e9a5af4f925f5ebfe.tar.zst
mandoc-de25e57757f7ad49514c641e9a5af4f925f5ebfe.zip
Do not segfault when there are two .Dt macros, the first without
an architecture argument and the second with an invalid one. Bug found by jsg@ with afl(1).
-rw-r--r--mdoc_validate.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 3a9b86f3..e95bebfa 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.352 2017/08/02 13:29:04 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.353 2017/09/12 18:21:03 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1914,7 +1914,10 @@ post_root(POST_ARGS)
arch++;
if (*arch == NULL) {
n = mdoc->first->child;
- while (n->tok != MDOC_Dt)
+ while (n->tok != MDOC_Dt ||
+ n->child == NULL ||
+ n->child->next == NULL ||
+ n->child->next->next == NULL)
n = n->next;
n = n->child->next->next;
mandoc_vmsg(MANDOCERR_ARCH_BAD,