summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea/cnf.c
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-08-13 22:43:09 +0000
committerKarl Berry <karl@freefriends.org>2019-08-13 22:43:09 +0000
commit0104a8417f2ddda2d30bbfa2b7fa33e75405676a (patch)
tree6a068385addff93e0ebf338b23f76be88b64db43 /Build/source/texk/kpathsea/cnf.c
parent43853632d39f7c6ddc69d0d5adbb2d336e450c4a (diff)
warn about unusual characters in program name qualifiers
git-svn-id: svn://tug.org/texlive/trunk@51875 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea/cnf.c')
-rw-r--r--Build/source/texk/kpathsea/cnf.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/Build/source/texk/kpathsea/cnf.c b/Build/source/texk/kpathsea/cnf.c
index def8f97c77e..14f7e04e706 100644
--- a/Build/source/texk/kpathsea/cnf.c
+++ b/Build/source/texk/kpathsea/cnf.c
@@ -103,7 +103,7 @@ do_line (kpathsea kpse, string line, boolean env_progname)
strncpy (var, start, len);
var[len] = 0;
- /* If the variable is qualified with a program name, find out which. */
+ /* If the variable is qualified with a program name, extract it. */
while (*line && ISSPACE (*line))
line++;
if (*line == '.') {
@@ -115,12 +115,30 @@ do_line (kpathsea kpse, string line, boolean env_progname)
while (*line && !ISSPACE (*line) && *line != '=')
line++;
- /* It's annoying to repeat all this, but making a tokenizing
- subroutine would be just as long and annoying. */
+ /* The program name is what's in between. */
len = line - start;
prog = (string) xmalloc (len + 1);
strncpy (prog, start, len);
prog[len] = 0;
+ /* If the name is empty, or contains one of our usual special
+ characters, it's probably a mistake. For instance, a cnf line
+ foo .;bar
+ is interpreted as a program name ";bar", because the = between
+ the variable name and value is optional. We don't try to guess
+ the user's intentions, but just give a warning. */
+ if (len == 0) {
+ return ("Empty program name qualifier");
+ } else {
+ unsigned i;
+ for (i = 0; i < len; i++) {
+ if (prog[i] == '$' || prog[i] == '{' || prog[i] == '}'
+ || IS_KPSE_SEP (prog[i])) {
+ string msg = xmalloc (50);
+ sprintf (msg, "Unlikely character %c in program name", prog[i]);
+ return msg;
+ }
+ }
+ }
}
/* Skip whitespace, an optional =, more whitespace. */