summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-01-19 17:04:02 +0000
committerKarl Berry <karl@freefriends.org>2020-01-19 17:04:02 +0000
commiteeb7eab0a55e0bb85518b0fed6776c40cca8df80 (patch)
tree44b689f7d705d0d8ddbd16f6339d7c841d9d25e8 /Build
parent8a8104081ac2b2038544981a21b6e6dd69602ebb (diff)
drop NUL (zero) bytes in texmf.cnf and other files read by kpse
git-svn-id: svn://tug.org/texlive/trunk@53454 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog7
-rw-r--r--Build/source/texk/kpathsea/Makefile.am5
-rw-r--r--Build/source/texk/kpathsea/Makefile.in9
-rw-r--r--Build/source/texk/kpathsea/line.c7
-rwxr-xr-xBuild/source/texk/kpathsea/tests/cnfnull.test23
5 files changed, 44 insertions, 7 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index dffcdc1a284..cd2a1c1b05e 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,10 @@
+2020-01-19 Karl Berry <karl@freefriends.org>
+
+ * line.c (read_line): silently drop nul (zero) bytes.
+ * tests/cnfnull.test: test for nul bytes in texmf.cnf.
+ * Makefile.am (TESTS),
+ (tests/cnfnull.test): add it.
+
2020-01-16 Karl Berry <karl@freefriends.org>
* doc/kpathsea.texi,
diff --git a/Build/source/texk/kpathsea/Makefile.am b/Build/source/texk/kpathsea/Makefile.am
index ebb2c5f2cc8..a63b859f261 100644
--- a/Build/source/texk/kpathsea/Makefile.am
+++ b/Build/source/texk/kpathsea/Makefile.am
@@ -275,11 +275,12 @@ uninstall-local:
AM_TESTS_ENVIRONMENT = LN_S='$(LN_S)'; export LN_S;
AM_TESTS_ENVIRONMENT += LT_OBJDIR='$(LT_OBJDIR)'; export LT_OBJDIR;
#
-TESTS = tests/cnfline.test tests/cnfnewline.test tests/cnfprog.test
+TESTS = tests/cnfline.test tests/cnfnewline.test
+TESTS += tests/cnfnull.test tests/cnfprog.test
TESTS += tests/kpseaccess.test
TESTS += tests/kpsereadlink.test tests/kpsestat.test tests/kpsewhich.test
#
-tests/cnfline.log tests/cnfnewline.log tests/cnfprog.log \
+tests/cnfline.log tests/cnfnewline.log tests/cnfnull.log tests/cnfprog.log \
tests/kpsewhich.log: kpsewhich$(EXEEXT)
tests/kpseaccess.log: kpseaccess$(EXEEXT)
tests/kpsereadlink.log: kpsereadlink$(EXEEXT)
diff --git a/Build/source/texk/kpathsea/Makefile.in b/Build/source/texk/kpathsea/Makefile.in
index c4a4364bcbd..6f17519e45a 100644
--- a/Build/source/texk/kpathsea/Makefile.in
+++ b/Build/source/texk/kpathsea/Makefile.in
@@ -858,9 +858,10 @@ dist_noinst_DATA = texmf.cnf
AM_TESTS_ENVIRONMENT = LN_S='$(LN_S)'; export LN_S; \
LT_OBJDIR='$(LT_OBJDIR)'; export LT_OBJDIR;
#
-TESTS = tests/cnfline.test tests/cnfnewline.test tests/cnfprog.test \
- tests/kpseaccess.test tests/kpsereadlink.test \
- tests/kpsestat.test tests/kpsewhich.test
+TESTS = tests/cnfline.test tests/cnfnewline.test tests/cnfnull.test \
+ tests/cnfprog.test tests/kpseaccess.test \
+ tests/kpsereadlink.test tests/kpsestat.test \
+ tests/kpsewhich.test
# Rebuild
rebuild_prereq =
@@ -2422,7 +2423,7 @@ uninstall-local:
else :; fi; \
done
#
-tests/cnfline.log tests/cnfnewline.log tests/cnfprog.log \
+tests/cnfline.log tests/cnfnewline.log tests/cnfnull.log tests/cnfprog.log \
tests/kpsewhich.log: kpsewhich$(EXEEXT)
tests/kpseaccess.log: kpseaccess$(EXEEXT)
tests/kpsereadlink.log: kpsereadlink$(EXEEXT)
diff --git a/Build/source/texk/kpathsea/line.c b/Build/source/texk/kpathsea/line.c
index 6c66a302b7f..7d677a5599a 100644
--- a/Build/source/texk/kpathsea/line.c
+++ b/Build/source/texk/kpathsea/line.c
@@ -1,6 +1,6 @@
/* line.c: return the next line from a file, or NULL.
- Copyright 1992, 1993, 1995, 1996, 2008, 2013, 2014 Karl Berry.
+ Copyright 1992, 1993, 1995, 1996, 2008, 2013, 2014, 2020 Karl Berry.
Copyright 1998, 1999, 2001, 2005 Olaf Weber.
This library is free software; you can redistribute it and/or
@@ -55,6 +55,11 @@ read_line (FILE *f)
FLOCKFILE (f);
while ((c = getc (f)) != EOF && c != '\n' && c != '\r') {
+ /* Silently drop null bytes. */
+ if (c == 0) {
+ continue;
+ }
+
line[loc] = c;
loc++;
diff --git a/Build/source/texk/kpathsea/tests/cnfnull.test b/Build/source/texk/kpathsea/tests/cnfnull.test
new file mode 100755
index 00000000000..e80d931394c
--- /dev/null
+++ b/Build/source/texk/kpathsea/tests/cnfnull.test
@@ -0,0 +1,23 @@
+#!/bin/sh -vx
+# $Id$
+# Copyright 2020 Karl Berry <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+#
+# Test nul (zero) bytes in texmf.cnf.
+
+cnf_dir=cnfnull
+cnf_file=$cnf_dir/texmf.cnf
+
+# Create the texmf.cnf dynamically so we don't have to check in a file
+# containing nul bytes.
+rm -rf $cnf_dir
+mkdir $cnf_dir
+test -d $cnf_dir || exit 1
+printf 'x\0=1\n\0' >$cnf_file || exit 1
+
+val=`./kpsewhich "--cnf-line=TEXMFCNF=$cnf_dir" --var-value=x`
+test x"$val" = x1 || exit 1
+
+# Before we dropped nul bytes in 2020, kpse gave a warning:
+# warning: cnfnull/texmf.cnf:1: (kpathsea) No cnf value on line: x.
+# and did not assign anything (since the string ended with the x).