aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-02-11 21:49:50 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-02-11 21:49:50 +0000
commit751954a95b11620a0729815eee5feeaa166a265c (patch)
treebea7697eca75fdd5bc4181edacebcd1044cccca9 /man_term.c
parentd239cb85c79395e48ba21125d4726cd6b9325606 (diff)
downloadmandoc-751954a95b11620a0729815eee5feeaa166a265c.tar.gz
mandoc-751954a95b11620a0729815eee5feeaa166a265c.tar.zst
mandoc-751954a95b11620a0729815eee5feeaa166a265c.zip
Do not read one element past the end of the static const termacts array.
Bug found by Sevan Janiyan <venture37 at geeklan dot co dot uk> who ran the OpenBSD mandoc test suite on Ubuntu on POWER8 (sic!) and reported that mdoc/Sh/before.in failed in -Tman mode. If that isn't power testing, i don't know...
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/man_term.c b/man_term.c
index fd2fc993..0db372c4 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.189 2017/02/04 11:58:09 schwarze Exp $ */
+/* $Id: man_term.c,v 1.190 2017/02/11 21:49:50 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -822,7 +822,8 @@ pre_SH(DECL_ARGS)
do {
n = n->prev;
- } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT);
+ } while (n != NULL && n->tok < MAN_MAX &&
+ termacts[n->tok].flags & MAN_NOTEXT);
if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL))
break;