source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: when processing unknown output options, prevent passing NULL to
Date: Fri, 3 May 2019 13:24:24 -0500 (EST)	[thread overview]
Message-ID: <e3fef6e885d29a2e@fantadrom.bsd.lv> (raw)

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

                 reply	other threads:[~2019-05-03 18:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3fef6e885d29a2e@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).