source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: when processing unknown output options, prevent passing NULL to
@ 2019-05-03 18:24 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-05-03 18:24 UTC (permalink / raw)
  To: source

Log Message:
-----------
when processing unknown output options, prevent passing NULL to printf;
patch from anton@

Modified Files:
--------------
    mandoc:
        manpath.c

Revision Data
-------------
Index: manpath.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/manpath.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -Lmanpath.c -Lmanpath.c -u -p -r1.37 -r1.38
--- manpath.c
+++ manpath.c
@@ -235,12 +235,13 @@ manconf_output(struct manoutput *conf, c
 	    "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, c
 		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;
 	}
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-03 18:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 18:24 mandoc: when processing unknown output options, prevent passing NULL to schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).