From: schwarze Date: Mon, 20 Apr 2015 09:48:19 +0000 (+0000) Subject: Avoid out-of-bounds read access before the beginning of the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bfef5133781354310ad3c096593d7e3e3e0c04f4;p=openbsd 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. --- 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)