summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/xdvik/ChangeLog4
-rw-r--r--Build/source/texk/xdvik/dvi-init.c9
2 files changed, 12 insertions, 1 deletions
diff --git a/Build/source/texk/xdvik/ChangeLog b/Build/source/texk/xdvik/ChangeLog
index 814c55b58a8..9068838026c 100644
--- a/Build/source/texk/xdvik/ChangeLog
+++ b/Build/source/texk/xdvik/ChangeLog
@@ -1,5 +1,9 @@
2022-01-31 Karl Berry <karl@freefriends.org>
+ * dvi-init.c (file_exists_p): check for failed fstat.
+ Found by John Hawkinson, tlbuild 30 Jan 2022 22:42:23.
+ https://tug.org/pipermail/tlbuild/2022q1/005105.html
+
* xdvi.1.in: add 262144=find and 524288=files.
Found by John Hawkinson, tlbuild 30 Jan 2022 23:11:10.
diff --git a/Build/source/texk/xdvik/dvi-init.c b/Build/source/texk/xdvik/dvi-init.c
index 6126a08fe1b..127063d2f66 100644
--- a/Build/source/texk/xdvik/dvi-init.c
+++ b/Build/source/texk/xdvik/dvi-init.c
@@ -1242,7 +1242,14 @@ file_exists_p(const char *path, dviErrFlagT *errflag)
/* fprintf(stderr, "after internal_open_dvi2: xfopen\n"); */
/* shouldn't happen */
- if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
+ int rv = fstat(fileno(m_dvi_fp), &fstatbuf);
+ if (rv == -1) {
+ perror("xdvi: file_exists_p: fstat");
+ fclose(m_dvi_fp);
+ m_dvi_fp = NULL;
+ return False;
+ }
+ if (S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
*errflag = FILE_IS_DIRECTORY;
fclose(m_dvi_fp);
m_dvi_fp = NULL;