summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2017-09-12 18:20:32 +0000
committerschwarze <schwarze@openbsd.org>2017-09-12 18:20:32 +0000
commit3f450c8c9960de5151e0748c59153fc4bdc71149 (patch)
treee4ea6f4666e7872776d8fbfe80da7fa9e03de85d
parentthere is no offical way to get the max value of time_t, but this one works (diff)
downloadwireguard-openbsd-3f450c8c9960de5151e0748c59153fc4bdc71149.tar.xz
wireguard-openbsd-3f450c8c9960de5151e0748c59153fc4bdc71149.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--usr.bin/mandoc/mdoc_validate.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index c9d4290ac10..39bd00b0e83 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.267 2017/08/02 13:28:35 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.268 2017/09/12 18:20:32 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1899,7 +1899,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,