From bfef5133781354310ad3c096593d7e3e3e0c04f4 Mon Sep 17 00:00:00 2001 From: schwarze Date: Mon, 20 Apr 2015 09:48:19 +0000 Subject: [PATCH] Avoid out-of-bounds read access before the beginning of the mdoc_macros[] array. This sometimes prevented proper warnings about text nodes preceding the first section header. --- usr.bin/mandoc/mdoc_validate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index a09488b1322..0063abd80cc 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.205 2015/04/19 14:25:05 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.206 2015/04/20 09:48:19 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -1553,7 +1553,8 @@ post_root(POST_ARGS) /* Check that we begin with a proper `Sh'. */ n = mdoc->first->child; - while (n != NULL && mdoc_macros[n->tok].flags & MDOC_PROLOGUE) + while (n != NULL && n->tok != TOKEN_NONE && + mdoc_macros[n->tok].flags & MDOC_PROLOGUE) n = n->next; if (n == NULL) -- 2.20.1