summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2022-06-06 11:34:11 +0000
committermartin <martin@NetBSD.org>2022-06-06 11:34:11 +0000
commit0a36d80a2919c1446f1e8706df868736347b498f (patch)
tree9492f7cf9e4272fc7afff37aa74eccab2ee758ea
parent0fdbfe88ca6cee12bea0270bdc768c10718d3403 (diff)
Pull up following revision(s) (requested by skrll in ticket #1465):
usr.sbin/makemandb/makemandb.c: revision 1.63 Don't index outside the mdocs array of function pointers. Analysis and suggested fixes from Tom Lane. I played it safe and went with (my variation of) the minimal fix. PR port-hppa/56118: sporadic app crashes in HPPA -current
-rw-r--r--usr.sbin/makemandb/makemandb.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/usr.sbin/makemandb/makemandb.c b/usr.sbin/makemandb/makemandb.c
index bfca6f9e914..e7f7bbd456b 100644
--- a/usr.sbin/makemandb/makemandb.c
+++ b/usr.sbin/makemandb/makemandb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: makemandb.c,v 1.60 2019/05/18 07:56:43 abhinav Exp $ */
+/* $NetBSD: makemandb.c,v 1.60.2.1 2022/06/06 11:34:11 martin Exp $ */
/*
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.60 2019/05/18 07:56:43 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.60.2.1 2022/06/06 11:34:11 martin Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -1079,15 +1079,18 @@ mdoc_parse_Sh(const struct roff_node *n, mandb_rec *rec)
if (n->type == ROFFT_TEXT) {
mdoc_parse_section(n->sec, n->string, rec);
- } else if (mdocs[n->tok] == pmdoc_Xr) {
- /*
- * When encountering other inline macros,
- * call pmdoc_macro_handler.
- */
- pmdoc_macro_handler(n, rec, MDOC_Xr);
- xr_found = 1;
- } else if (mdocs[n->tok] == pmdoc_Pp) {
- pmdoc_macro_handler(n, rec, MDOC_Pp);
+ } else if (n->tok >= MDOC_Dd && n->tok < MDOC_MAX) {
+ const int tok_idx = n->tok - MDOC_Dd;
+ if (mdocs[tok_idx] == pmdoc_Xr) {
+ /*
+ * When encountering other inline macros,
+ * call pmdoc_macro_handler.
+ */
+ pmdoc_macro_handler(n, rec, MDOC_Xr);
+ xr_found = 1;
+ } else if (mdocs[tok_idx] == pmdoc_Pp) {
+ pmdoc_macro_handler(n, rec, MDOC_Pp);
+ }
}
/*