summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/man_term.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2017-02-11 21:49:43 +0000
committerschwarze <schwarze@openbsd.org>2017-02-11 21:49:43 +0000
commit73eff99fad6406cf29d61ccc94c52a57e3689467 (patch)
treec1411f0e467e9d8439a59bd69d0d5caa29c965f3 /usr.bin/mandoc/man_term.c
parentCorrect handling of requests to delete individual attribute values. (diff)
downloadwireguard-openbsd-73eff99fad6406cf29d61ccc94c52a57e3689467.tar.xz
wireguard-openbsd-73eff99fad6406cf29d61ccc94c52a57e3689467.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 'usr.bin/mandoc/man_term.c')
-rw-r--r--usr.bin/mandoc/man_term.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index c1db2c0dd47..1594f3312f8 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.142 2017/02/04 11:56:48 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.143 2017/02/11 21:49:43 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -820,7 +820,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;