summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
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
commit8aeee8c83fca34072d530314dc724856ca46e74c (patch)
treefa455714df2f5fa90671c66e865009c379c9d68c /mdoc_validate.c
parentb99b10fd0c42fb887260394bc4de5ca7e60d4a9a (diff)
downloadmandoc-8aeee8c83fca34072d530314dc724856ca46e74c.tar.gz
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).
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index fe238eef..a14cb9d0 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -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,