summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-11-17 23:38:04 +0000
committerKarl Berry <karl@freefriends.org>2017-11-17 23:38:04 +0000
commit82d58e473ee47e5ad8f3d6989347fb95ab7d36ea (patch)
treee5ce320ac5e7f3cd932731de3877c522b65fe5f6 /Build
parentc3ade43e7a77c7ba8035aeb2b592b2f6ab0795fc (diff)
(elt_in_db): protect against pathological arguments
git-svn-id: svn://tug.org/texlive/trunk@45841 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog5
-rw-r--r--Build/source/texk/kpathsea/db.c10
2 files changed, 15 insertions, 0 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index c05a72df8f2..1cb0690e38c 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-18 Karl Berry <karl@tug.org>
+
+ * db.c (elt_in_db): protect against either argument being NULL or
+ empty. From Doug McKenna, personal mail, 17nov17.
+
2017-11-11 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* tex-file.c: Again use a custom kpathsea_getlongpath()
diff --git a/Build/source/texk/kpathsea/db.c b/Build/source/texk/kpathsea/db.c
index 16d4941d81e..fb4658c1968 100644
--- a/Build/source/texk/kpathsea/db.c
+++ b/Build/source/texk/kpathsea/db.c
@@ -296,6 +296,7 @@ match (const_string filename, const_string path_elt)
That is, the question is whether to try the db for a file looked up
in PATH_ELT. If PATH_ELT == ".", for example, the answer is no. If
PATH_ELT == "/usr/local/lib/texmf/fonts//tfm", the answer is yes.
+ If either string is NULL or empty, return false.
In practice, ls-R is only needed for lengthy subdirectory
comparisons, but there's no gain to checking PATH_ELT to see if it is
@@ -307,6 +308,15 @@ elt_in_db (const_string db_dir, const_string path_elt)
{
boolean found = false;
+ /* If both strings are empty or null return false on the grounds that
+ it's useless to do anything further with such a strange case (which
+ likely never happens). In theory one could argue that the empty
+ string is a prefix of any other string, but let's just declare the
+ result otherwise. */
+ if (db_dir == NULL || *db_dir == 0
+ || path_elt == NULL || *path_elt == 0)
+ return false;
+
while (!found && FILECHARCASEEQ (*db_dir++, *path_elt++)) {
/* If we've matched the entire db directory, it's good. */
if (*db_dir == 0)