texlive[61829] Build/source/texk/xdvik: check fstat return

commits+karl at tug.org commits+karl at tug.org
Tue Feb 1 00:14:24 CET 2022


Revision: 61829
          http://tug.org/svn/texlive?view=revision&revision=61829
Author:   karl
Date:     2022-02-01 00:14:24 +0100 (Tue, 01 Feb 2022)
Log Message:
-----------
check fstat return

Modified Paths:
--------------
    trunk/Build/source/texk/xdvik/ChangeLog
    trunk/Build/source/texk/xdvik/dvi-init.c

Modified: trunk/Build/source/texk/xdvik/ChangeLog
===================================================================
--- trunk/Build/source/texk/xdvik/ChangeLog	2022-01-31 22:48:12 UTC (rev 61828)
+++ trunk/Build/source/texk/xdvik/ChangeLog	2022-01-31 23:14:24 UTC (rev 61829)
@@ -1,5 +1,9 @@
 2022-01-31  Karl Berry  <karl at 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.
 

Modified: trunk/Build/source/texk/xdvik/dvi-init.c
===================================================================
--- trunk/Build/source/texk/xdvik/dvi-init.c	2022-01-31 22:48:12 UTC (rev 61828)
+++ trunk/Build/source/texk/xdvik/dvi-init.c	2022-01-31 23:14:24 UTC (rev 61829)
@@ -1242,7 +1242,14 @@
     /*      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;



More information about the tex-live-commits mailing list.