texlive[53760] Build/source/texk/dvipdfm-x: Fix a potential bug in

commits+kakuto at tug.org commits+kakuto at tug.org
Wed Feb 12 00:05:24 CET 2020


Revision: 53760
          http://tug.org/svn/texlive?view=revision&revision=53760
Author:   kakuto
Date:     2020-02-12 00:05:24 +0100 (Wed, 12 Feb 2020)
Log Message:
-----------
Fix a potential bug in set_default_pdf_filename().

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/dvipdfmx.c

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-02-11 22:10:41 UTC (rev 53759)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-02-11 23:05:24 UTC (rev 53760)
@@ -1,3 +1,8 @@
+2020-02-12  Akira Kakuto  <kakuto at w32tex.org>
+
+	* dvipdfmx.c: Fix a potential bug in set_default_pdf_filename().
+	see https://tug.org/pipermail/tex-live/2020-February/044731.html
+
 2020-02-06  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
 
 	* pdfobj.c: In pdf_new_string(), the supplied string was

Modified: trunk/Build/source/texk/dvipdfm-x/dvipdfmx.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/dvipdfmx.c	2020-02-11 22:10:41 UTC (rev 53759)
+++ trunk/Build/source/texk/dvipdfm-x/dvipdfmx.c	2020-02-11 23:05:24 UTC (rev 53760)
@@ -134,15 +134,21 @@
   size_t      len = 0;
 
   dvi_base = xbasename(dvi_filename);
-  len      = strlen(dvi_base) - strlen(".dvi");
-  suffix   = dvi_base + len;
-  if (dpx_conf.compat_mode == dpx_mode_mpost_mode && len > 0 &&
+
+  suffix = strrchr(dvi_base, '.');
+  /* suffix can be dvi_base if dvi_base is like ".abcde" */
+
+  if (suffix == NULL || suffix == dvi_base) {
+    suffix = dvi_base + strlen(dvi_base);
+  }
+  len = strlen(dvi_base) - strlen(suffix);
+
+  if (dpx_conf.compat_mode == dpx_mode_mpost_mode &&
       FILESTRCASEEQ(".mps", suffix)) {
     pdf_filename = NEW(len+strlen(".pdf")+1, char);
     strncpy(pdf_filename, dvi_base, len);
     pdf_filename[len] = '\0';
-  } else if (len > 0 &&
-             (FILESTRCASEEQ(".dvi", suffix) ||
+  } else if ((FILESTRCASEEQ(".dvi", suffix) ||
               FILESTRCASEEQ(".xdv", suffix))) {
     pdf_filename = NEW(len+strlen(".pdf")+1, char);
     strncpy(pdf_filename, dvi_base, len);



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