texlive[56648] Build/source/texk/dvipdfm-x: Fix a bug accessing wrong

commits+kakuto at tug.org commits+kakuto at tug.org
Tue Oct 13 22:48:02 CEST 2020


Revision: 56648
          http://tug.org/svn/texlive?view=revision&revision=56648
Author:   kakuto
Date:     2020-10-13 22:48:02 +0200 (Tue, 13 Oct 2020)
Log Message:
-----------
Fix a bug accessing wrong array indices. (S. Hirata)

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/cidtype2.c
    trunk/Build/source/texk/dvipdfm-x/configure
    trunk/Build/source/texk/dvipdfm-x/configure.ac
    trunk/Build/source/texk/dvipdfm-x/tt_cmap.c

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-10-12 23:53:19 UTC (rev 56647)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-10-13 20:48:02 UTC (rev 56648)
@@ -1,3 +1,11 @@
+2020-10-14  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
+
+	* tt_cmap.c: Fix a bug that checking array indices is wrong.
+	* cidtype2.c: Warning message when CID is mapped to a sequence
+	of several Unicode characters is corrected. Fix a wrong
+	assumption introduced by xdvipdfmx.
+	* configure.ac: Version 20201014.
+
 2020-10-08  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
 
 	* dvi.c: Fix problems introduced by the changes on 2020/10/03.

Modified: trunk/Build/source/texk/dvipdfm-x/cidtype2.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/cidtype2.c	2020-10-12 23:53:19 UTC (rev 56647)
+++ trunk/Build/source/texk/dvipdfm-x/cidtype2.c	2020-10-13 20:48:02 UTC (rev 56648)
@@ -34,6 +34,8 @@
 #include "dpxconf.h"
 #include "dpxfile.h"
 
+#include "unicode.h"
+
 #include "pdfobj.h"
 /* pseudo unique tag */
 #include "pdffont.h"
@@ -434,8 +436,8 @@
   return alt_code;
 }
 
-static int
-cid_to_code (CMap *cmap, CID cid)
+static int32_t
+cid_to_code (CMap *cmap, CID cid, int unicode_cmap)
 {
   unsigned char  inbuf[2], outbuf[32];
   int            inbytesleft = 2, outbytesleft = 32;
@@ -452,22 +454,29 @@
   CMap_decode_char(cmap, &p, &inbytesleft, &q, &outbytesleft);
 
   if (inbytesleft != 0)
-    return 0;
+    return -1;
   else if (outbytesleft == 31)
-    return (int) outbuf[0];
+    return (int32_t) outbuf[0];
   else if (outbytesleft == 30)
-    return (int) (outbuf[0] << 8|outbuf[1]);
-  else if (outbytesleft == 28) { /* We assume the output encoding is UTF-16. */
-    CID hi, lo;
-    hi = outbuf[0] << 8|outbuf[1];
-    lo = outbuf[2] << 8|outbuf[3];
-    if (hi >= 0xd800 && hi <= 0xdbff && lo >= 0xdc00 && lo <= 0xdfff)
-      return (int) ((hi - 0xd800) * 0x400 + 0x10000 + lo - 0xdc00);
-    else
-      return (int) (hi << 16|lo);
+    return (int32_t) (outbuf[0] << 8|outbuf[1]);
+  else if (outbytesleft == 28) {
+    if (unicode_cmap) {
+      /* We assume the output encoding is UTF-16. */
+      int32_t              uc;
+      const unsigned char *endptr;
+
+      p      = outbuf;
+      endptr = p + 4;
+      uc = UC_UTF16BE_decode_char(&p, endptr);
+      if (p != endptr)
+        WARN("CID=%u mapped to non-single Unicode characters...", cid);
+      return p == endptr ? uc : -1;
+    } else {
+      return (outbuf[0] << 24)|(outbuf[1] << 16)|(outbuf[2] << 8)|outbuf[3];
+    }
   }
 
-  return 0;
+  return -1;
 }
 
 /* #define NO_GHOSTSCRIPT_BUG 1 */
@@ -693,8 +702,8 @@
   if (h_used_chars) {
     used_chars = h_used_chars;
     for (cid = 1; cid <= last_cid; cid++) {
-      int            code;
-      unsigned short gid;
+      int32_t  code;
+      uint16_t gid = 0;
 
       if (!is_used_char2(h_used_chars, cid))
         continue;
@@ -703,25 +712,29 @@
         gid  = cid;
         code = cid;
       } else {
-        code = cid_to_code(cmap, cid);
-        gid  = tt_cmap_lookup(ttcmap, code);
+        code = cid_to_code(cmap, cid, unicode_cmap);
+        if (code < 0) {
+          WARN("Unable to map CID to code: CID=%u", cid);
+        } else {
+          gid  = tt_cmap_lookup(ttcmap, code);
 #ifdef FIX_CJK_UNIOCDE_SYMBOLS
-        if (gid == 0 && unicode_cmap) {
-          int alt_code;
+          if (gid == 0 && unicode_cmap) {
+            int alt_code;
           
-          alt_code = fix_CJK_symbols((unsigned short)code);
-          if (alt_code != code) {
-            gid = tt_cmap_lookup(ttcmap, alt_code);
-            if (gid != 0) {
-              WARN("Unicode char U+%04x replaced with U+%04x.", code, alt_code);
+            alt_code = fix_CJK_symbols((unsigned short)code);
+            if (alt_code != code) {
+              gid = tt_cmap_lookup(ttcmap, alt_code);
+              if (gid != 0) {
+                WARN("Unicode char U+%04x replaced with U+%04x.", code, alt_code);
+              }
             }
           }
+#endif /* FIX_CJK_UNIOCDE_SYMBOLS */
         }
-#endif /* FIX_CJK_UNIOCDE_SYMBOLS */
       }
-
       if (gid == 0) {
-        WARN("Glyph missing in font. (CID=%u, code=0x%04x)", cid, code);
+        if (code >= 0)
+          WARN("Glyph missing in font. (CID=%u, code=0x%04x)", cid, code);
       }
 
       /* TODO: duplicated glyph */
@@ -764,8 +777,8 @@
     }
 
     for (cid = 1; cid <= last_cid; cid++) {
-      int            code;
-      unsigned short gid;
+      int32_t  code;
+      uint16_t gid = 0;
 
       if (!is_used_char2(v_used_chars, cid))
         continue;
@@ -782,24 +795,29 @@
         gid  = cid;
         code = cid;
       } else {
-        code = cid_to_code(cmap, cid);
-        gid  = tt_cmap_lookup(ttcmap, code);
+        code = cid_to_code(cmap, cid, unicode_cmap);
+        if (code < 0) {
+          WARN("Unable to map CID to code: CID=%u", cid);
+        } else {
+          gid  = tt_cmap_lookup(ttcmap, code);
 #ifdef FIX_CJK_UNIOCDE_SYMBOLS
-        if (gid == 0 && unicode_cmap) {
-          int alt_code;
+          if (gid == 0 && unicode_cmap) {
+            int alt_code;
           
-          alt_code = fix_CJK_symbols((unsigned short)code);
-          if (alt_code != code) {
-            gid = tt_cmap_lookup(ttcmap, alt_code);
-            if (gid != 0) {
-              WARN("Unicode char U+%04x replaced with U+%04x.", code, alt_code);
+            alt_code = fix_CJK_symbols((unsigned short)code);
+            if (alt_code != code) {
+              gid = tt_cmap_lookup(ttcmap, alt_code);
+              if (gid != 0) {
+                WARN("Unicode char U+%04x replaced with U+%04x.", code, alt_code);
+              }
             }
           }
+#endif /* FIX_CJK_UNIOCDE_SYMBOLS */
         }
-#endif /* FIX_CJK_UNIOCDE_SYMBOLS */
       }
       if (gid == 0) {
-        WARN("Glyph missing in font. (CID=%u, code=0x%04x)", cid, code);
+        if (code >= 0)
+          WARN("Glyph missing in font. (CID=%u, code=0x%04x)", cid, code);
       } else if (gsub_list) {
         otl_gsub_apply(gsub_list, &gid);
       }

Modified: trunk/Build/source/texk/dvipdfm-x/configure
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure	2020-10-12 23:53:19 UTC (rev 56647)
+++ trunk/Build/source/texk/dvipdfm-x/configure	2020-10-13 20:48:02 UTC (rev 56648)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20201008.
+# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20201014.
 #
 # Report bugs to <dvipdfmx at tug.org>.
 #
@@ -590,8 +590,8 @@
 # Identity of this package.
 PACKAGE_NAME='dvipdfm-x (TeX Live)'
 PACKAGE_TARNAME='dvipdfm-x--tex-live-'
-PACKAGE_VERSION='20201008'
-PACKAGE_STRING='dvipdfm-x (TeX Live) 20201008'
+PACKAGE_VERSION='20201014'
+PACKAGE_STRING='dvipdfm-x (TeX Live) 20201014'
 PACKAGE_BUGREPORT='dvipdfmx at tug.org'
 PACKAGE_URL=''
 
@@ -1350,7 +1350,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures dvipdfm-x (TeX Live) 20201008 to adapt to many kinds of systems.
+\`configure' configures dvipdfm-x (TeX Live) 20201014 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1421,7 +1421,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20201008:";;
+     short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20201014:";;
    esac
   cat <<\_ACEOF
 
@@ -1551,7 +1551,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-dvipdfm-x (TeX Live) configure 20201008
+dvipdfm-x (TeX Live) configure 20201014
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2390,7 +2390,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by dvipdfm-x (TeX Live) $as_me 20201008, which was
+It was created by dvipdfm-x (TeX Live) $as_me 20201014, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -8077,7 +8077,7 @@
 
 # Define the identity of the package.
  PACKAGE='dvipdfm-x--tex-live-'
- VERSION='20201008'
+ VERSION='20201014'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -14746,7 +14746,7 @@
 Report bugs to <bug-libtool at gnu.org>."
 
 lt_cl_version="\
-dvipdfm-x (TeX Live) config.lt 20201008
+dvipdfm-x (TeX Live) config.lt 20201014
 configured by $0, generated by GNU Autoconf 2.69.
 
 Copyright (C) 2011 Free Software Foundation, Inc.
@@ -16636,7 +16636,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by dvipdfm-x (TeX Live) $as_me 20201008, which was
+This file was extended by dvipdfm-x (TeX Live) $as_me 20201014, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16706,7 +16706,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-dvipdfm-x (TeX Live) config.status 20201008
+dvipdfm-x (TeX Live) config.status 20201014
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 

Modified: trunk/Build/source/texk/dvipdfm-x/configure.ac
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure.ac	2020-10-12 23:53:19 UTC (rev 56647)
+++ trunk/Build/source/texk/dvipdfm-x/configure.ac	2020-10-13 20:48:02 UTC (rev 56648)
@@ -8,7 +8,7 @@
 dnl   gives unlimited permission to copy and/or distribute it,
 dnl   with or without modifications, as long as this notice is preserved.
 dnl
-AC_INIT([dvipdfm-x (TeX Live)], [20201008], [dvipdfmx at tug.org])
+AC_INIT([dvipdfm-x (TeX Live)], [20201014], [dvipdfmx at tug.org])
 AC_PREREQ([2.65])
 AC_CONFIG_SRCDIR([agl.c])
 AC_CONFIG_AUX_DIR([../../build-aux])

Modified: trunk/Build/source/texk/dvipdfm-x/tt_cmap.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/tt_cmap.c	2020-10-12 23:53:19 UTC (rev 56647)
+++ trunk/Build/source/texk/dvipdfm-x/tt_cmap.c	2020-10-13 20:48:02 UTC (rev 56648)
@@ -434,7 +434,7 @@
   int i;
 
   i = map->nGroups;
-  while (i-- >= 0 &&
+  while (i-- > 0 &&
 	 cccc <= map->groups[i].endCharCode) {
     if (cccc >= map->groups[i].startCharCode) {
       gid = (USHORT) ((cccc -



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