Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/man Check _build and _crunch commands with fmtcheck(...



details:   https://anonhg.NetBSD.org/src/rev/be4b3452ffcd
branches:  trunk
changeset: 326765:be4b3452ffcd
user:      uwe <uwe%NetBSD.org@localhost>
date:      Mon Feb 17 02:53:48 2014 +0000

description:
Check _build and _crunch commands with fmtcheck(3), warn about and
ignore bad ones.

diffstat:

 usr.bin/man/manconf.c |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (47 lines):

diff -r 8dabee0ecc3a -r be4b3452ffcd usr.bin/man/manconf.c
--- a/usr.bin/man/manconf.c     Mon Feb 17 02:38:46 2014 +0000
+++ b/usr.bin/man/manconf.c     Mon Feb 17 02:53:48 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: manconf.c,v 1.7 2013/07/18 15:39:08 christos Exp $     */
+/*     $NetBSD: manconf.c,v 1.8 2014/02/17 02:53:48 uwe Exp $  */
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -45,7 +45,7 @@
 #if 0
 static char sccsid[] = "@(#)config.c   8.8 (Berkeley) 1/31/95";
 #else
-__RCSID("$NetBSD: manconf.c,v 1.7 2013/07/18 15:39:08 christos Exp $");
+__RCSID("$NetBSD: manconf.c,v 1.8 2014/02/17 02:53:48 uwe Exp $");
 #endif
 #endif /* not lint */
 
@@ -147,6 +147,8 @@
                         * rest of the line as a single entry.
                         */
                        if (!strcmp(p, "_build") || !strcmp(p, "_crunch")) {
+                               const char *u;
+
                                /*
                                 * The reason we're not just using
                                 * strtok(3) for all of the parsing is
@@ -154,6 +156,19 @@
                                 * has only a single token on it.
                                 */
                                while (*++t && isspace((unsigned char)*t));
+#ifndef HAVE_NBTOOL_CONFIG_H
+                               /* pre-verify user-supplied command format */
+                               u = t;
+                               while (*u && !isspace((unsigned char)*u))
+                                       ++u;
+                               while (*u && isspace((unsigned char)*u))
+                                       ++u;
+                               if (fmtcheck(u, "%s") != u) {
+                                       warnx("%s:%d: invalid %s command ignored",
+                                             fname, lcnt, p);
+                                       continue;
+                               }
+#endif /* !HAVE_NBTOOL_CONFIG_H */
                                if (addentry(tp, t, 0) == -1)
                                        errx(EXIT_FAILURE,
                                            "addentry: malloc failed");



Home | Main Index | Thread Index | Old Index