summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-02-20 19:15:58 +0000
committerKarl Berry <karl@freefriends.org>2018-02-20 19:15:58 +0000
commite398dbb367c9b4c96fcc0396e7a024f02d9539f9 (patch)
tree603862f29c87c32792d5f48aa88fe6fa835305f0 /Build
parent7c1e49f3f8af11f0fd9e70027017b318ac81fea7 (diff)
quit if asked to set a nonexistent program name
git-svn-id: svn://tug.org/texlive/trunk@46686 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog8
-rw-r--r--Build/source/texk/kpathsea/progname.c40
2 files changed, 24 insertions, 24 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index f7d8b724a27..32fbbfd746b 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,11 @@
+2018-02-20 Karl Berry <karl@freefriends.org>
+
+ * progname.c (expand_symlinks): make error message on unresolvable
+ symlinks less verbose.
+ (kpathsea_selfdir): exit(1) if name cannot be resolved,
+ instead of failing an assertion. Report from Enrico Gregorio,
+ http://tug.org/pipermail/tex-live/2018-February/041052.html
+
2018-02-17 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
* texmf.cnf ({TEXINPUTS,BIBINPUTS,max_strings}.upbibtex):
diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c
index 984fceadd6c..564aab1113a 100644
--- a/Build/source/texk/kpathsea/progname.c
+++ b/Build/source/texk/kpathsea/progname.c
@@ -153,8 +153,9 @@ CopyFirst (register char *a, char *b)
strcat (a, StripFirst (b));
}
-/* Returns NULL on error. Prints intermediate results if global
- `ll_verbose' is nonzero. */
+/* Returns NULL on error, such as an unresolvable symlink. Prints
+ intermediate results if global `ll_verbose' is nonzero. Otherwise,
+ returns a pointer to a static buffer (sorry). */
#define EMPTY_STRING(s) (*(s) == 0)
#define EX(s) (!EMPTY_STRING (s) && strcmp (s, "/") ? "/" : "")
@@ -171,22 +172,6 @@ expand_symlinks (kpathsea kpse, char *s)
struct stat st;
int done;
- /* Check for symlink loops. It's difficult to check for all the
- possibilities ourselves, so let the kernel do it. And make it
- conditional so that people can see where the infinite loop is
- being caused (see engtools#1536). */
- /* There used to be a test for a variable |ll_loop| here, but
- it was initialized to zero and never updated */
- if (0) {
- FILE *f = fopen (s, "r");
- if (!f && errno == ELOOP) {
- /* Not worried about other errors, we'll get to them in due course. */
- perror (s);
- return NULL;
- }
- if (f) fclose (f);
- }
-
strcpy (post, s);
strcpy (pre, "");
@@ -194,7 +179,7 @@ expand_symlinks (kpathsea kpse, char *s)
CopyFirst (pre, post);
if (lstat (pre, &st) != 0) {
- fprintf (stderr, "lstat(%s) failed ...\n", pre);
+ fprintf (stderr, "lstat(%s) failed: ", pre);
perror (pre);
return NULL;
}
@@ -327,14 +312,14 @@ remove_dots (kpathsea kpse, string dir)
}
/* Return directory ARGV0 comes from. Check PATH if ARGV0 is not
- absolute. */
+ absolute. If ARGV0 cannot be found (e.g., --progname=nonesuch), quit. */
string
kpathsea_selfdir (kpathsea kpse, const_string argv0)
{
- string self = NULL;
string name;
string ret;
+ string self = NULL;
if (kpathsea_absolute_p (kpse, argv0, true)) {
self = xstrdup (argv0);
@@ -394,16 +379,23 @@ kpathsea_selfdir (kpathsea kpse, const_string argv0)
if (!self)
self = concat3 (".", DIR_SEP_STRING, argv0);
- name = remove_dots (kpse, expand_symlinks (kpse, self));
+ /* If we can't expand symlinks (--progname=nonesuch), give up. */
+ name = expand_symlinks (kpse, self);
+ if (!name) {
+ fprintf (stderr, "kpathsea: Can't get directory of program name: %s\n",
+ self);
+ exit (1);
+ }
+
+ /* If we have something real, we can resolve ./ and ../ elements. */
+ name = remove_dots (kpse, name);
#ifndef AMIGA
free (self);
#endif
ret = xdirname (name);
-
free (name);
-
return ret;
}