summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authoranton <anton@cvs.openbsd.org>2019-05-03 17:45:18 +0000
committeranton <anton@cvs.openbsd.org>2019-05-03 17:45:18 +0000
commit9ebaa66b233840a291548da6672085bc9e456475 (patch)
tree4183f18b8e60f3d65553c55a49a88d25e8c44b3a /usr.bin
parent6fa3eca33cd78229930bdaefde3fed8710cbb0e7 (diff)
When processing unknown output options, prevent passing NULL to printf.
ok schwarze@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/manpath.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/mandoc/manpath.c b/usr.bin/mandoc/manpath.c
index c01309ac6d3..dac24a293bc 100644
--- a/usr.bin/mandoc/manpath.c
+++ b/usr.bin/mandoc/manpath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: manpath.c,v 1.24 2018/11/22 11:30:15 schwarze Exp $ */
+/* $OpenBSD: manpath.c,v 1.25 2019/05/03 17:45:17 anton Exp $ */
/*
* Copyright (c) 2011,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -235,12 +235,13 @@ manconf_output(struct manoutput *conf, const char *cp, int fromfile)
"includes", "man", "paper", "style", "indent", "width",
"tag", "fragment", "mdoc", "noval", "toc"
};
+ const size_t ntoks = sizeof(toks) / sizeof(toks[0]);
const char *errstr;
char *oldval;
size_t len, tok;
- for (tok = 0; tok < sizeof(toks)/sizeof(toks[0]); tok++) {
+ for (tok = 0; tok < ntoks; tok++) {
len = strlen(toks[tok]);
if ( ! strncmp(cp, toks[tok], len) &&
strchr(" = ", cp[len]) != NULL) {
@@ -257,7 +258,7 @@ manconf_output(struct manoutput *conf, const char *cp, int fromfile)
warnx("-O %s=?: Missing argument value", toks[tok]);
return -1;
}
- if (tok > 6 && *cp != '\0') {
+ if (tok > 6 && tok < ntoks && *cp != '\0') {
warnx("-O %s: Does not take a value: %s", toks[tok], cp);
return -1;
}