summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-01-31 23:14:24 +0000
committerKarl Berry <karl@freefriends.org>2022-01-31 23:14:24 +0000
commit08d2b03dc36105d78d8541b3380978dc16786d6a (patch)
tree491bfa9b24849cff4ef215a51991d0af7845d894 /Build/source
parent885db855ae9e6c53cbdfbcae39867d24e28ed36b (diff)
check fstat return
git-svn-id: svn://tug.org/texlive/trunk@61829 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-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;