summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-10-29 21:53:23 +0000
committerKarl Berry <karl@freefriends.org>2017-10-29 21:53:23 +0000
commitff79b7825576708c2518de725682061ff51a97e7 (patch)
tree9b2313400291fe25c54ebfcc9dc11b529bc4b8c9 /Build
parent9ed0aff3ed67e24359789fc17ce74a1c316935f2 (diff)
(do_subdir): arg cannot be empty; make assert robust
git-svn-id: svn://tug.org/texlive/trunk@45639 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog6
-rw-r--r--Build/source/texk/kpathsea/elt-dirs.c10
2 files changed, 12 insertions, 4 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index a14b6d3ffe1..2ecf77cd4ea 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-29 Karl Berry <karl@freefriends.org>
+
+ * elt-dirs.c (do_subdir): assert must include elt_length>0
+ to guarantee the assert of elt[elt_length-1] is valid.
+ From Doug McKenna, personal mail, 29oct17.
+
2017-10-25 Karl Berry <karl@tug.org>
* expand.c (brace_expand): do not look past the terminating
diff --git a/Build/source/texk/kpathsea/elt-dirs.c b/Build/source/texk/kpathsea/elt-dirs.c
index 93041142b10..5db08f37099 100644
--- a/Build/source/texk/kpathsea/elt-dirs.c
+++ b/Build/source/texk/kpathsea/elt-dirs.c
@@ -1,6 +1,7 @@
/* elt-dirs.c: Translate a path element to its corresponding director{y,ies}.
- Copyright 1993, 1994, 1995, 1996, 1997, 2008, 2009, 2010, 2011, 2016 Karl Berry.
+ Copyright 1993, 1994, 1995, 1996, 1997, 2008, 2009, 2010, 2011, 2016,
+ 2017 Karl Berry.
Copyright 1997, 1998, 1999, 2000, 2005 Olaf Weber.
This library is free software; you can redistribute it and/or
@@ -100,7 +101,7 @@ static void expand_elt (kpathsea, str_llist_type *, string, unsigned);
/* POST is a pointer into the original element (which may no longer be
ELT) to just after the doubled DIR_SEP, perhaps to the null. Append
subdirectories of ELT (up to ELT_LENGTH, which must be a /) to
- STR_LIST_PTR. */
+ STR_LIST_PTR. ELT must not be the empty string (or NULL). */
#ifdef WIN32
/* Shared across recursive calls, it acts like a stack. */
@@ -127,8 +128,9 @@ do_subdir (kpathsea kpse, str_llist_type *str_list_ptr, string elt,
/* Some old compilers don't allow aggregate initialization. */
name = fn_copy0 (elt, elt_length);
- assert (IS_DIR_SEP_CH (elt[elt_length - 1])
- || IS_DEVICE_SEP (elt[elt_length - 1]));
+ assert (elt_length > 0
+ && (IS_DIR_SEP_CH (elt[elt_length - 1])
+ || IS_DEVICE_SEP (elt[elt_length - 1])));
#if defined (WIN32)
strcpy(dirname, FN_STRING(name));