texlive[65872] Build/source/texk/web2c/luatexdir: Fixed the "Invalid

commits+lscarso at tug.org commits+lscarso at tug.org
Sat Feb 18 18:30:30 CET 2023


Revision: 65872
          http://tug.org/svn/texlive?view=revision&revision=65872
Author:   lscarso
Date:     2023-02-18 18:30:30 +0100 (Sat, 18 Feb 2023)
Log Message:
-----------
Fixed the "Invalid unicode ranges in CMap beginbfrange operator bug" as in pdfTeX (Han The Thanh)

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/luatexdir/ChangeLog
    trunk/Build/source/texk/web2c/luatexdir/font/tounicode.c
    trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h

Modified: trunk/Build/source/texk/web2c/luatexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/ChangeLog	2023-02-18 16:14:57 UTC (rev 65871)
+++ trunk/Build/source/texk/web2c/luatexdir/ChangeLog	2023-02-18 17:30:30 UTC (rev 65872)
@@ -1,8 +1,10 @@
 2023-02-18  Luigi Scarso <luigi.scarso at gmail.com> 
+    * Fixed the "Invalid unicode ranges in CMap beginbfrange operator bug" as in pdfTeX (Hàn Thế Thành)
+
+2023-02-18  Luigi Scarso <luigi.scarso at gmail.com> 
     * new "late special" feature by Phelype Oleinik,
       heavily adapted by H.Hagen.
 
-
 2023-02-05  Luigi Scarso <luigi.scarso at gmail.com> 
     *  Fix typos (thanks to J. Friedrich) 
 

Modified: trunk/Build/source/texk/web2c/luatexdir/font/tounicode.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/font/tounicode.c	2023-02-18 16:14:57 UTC (rev 65871)
+++ trunk/Build/source/texk/web2c/luatexdir/font/tounicode.c	2023-02-18 17:30:30 UTC (rev 65872)
@@ -305,6 +305,21 @@
 }
 */
 
+static boolean is_last_byte_valid(int srcCode1, int srcCode2, long code)
+{
+    /*tex
+       Followin pdfTeX, when defining ranges of this type, the value of the last byte in the
+       string shall be less than or equal to 255 − (srcCode2 − srcCode1). This
+       ensures that the last byte of the string shall not be incremented past
+       255; otherwise, the result of mapping is undefined. 
+    */
+    char *s = strend(utf16be_str(code)) - 2;
+    long l = strtol(s, NULL, 16);
+    return l < 255 - (srcCode2 - srcCode1);
+}
+
+
+
 static int do_write_tounicode(PDF pdf, char **glyph_names, char *name, internal_font_number f)
 {
     char buf[SMALL_BUF_SIZE], *p, *s;
@@ -403,7 +418,8 @@
         } else {
             /*tex |gtab[i].code >= 0| */
             j = i;
-            while (i < 256 && gtab[i + 1].code >= 0 && gtab[i].code + 1 == gtab[i + 1].code)
+            while (i < 256 && gtab[i + 1].code >= 0 && gtab[i].code + 1 == gtab[i + 1].code && is_last_byte_valid(j, i, gtab[i].code)
+)
                 i++;
             /*tex
                 At this point |i| is the last entry of the subrange so we move |i| to

Modified: trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h	2023-02-18 16:14:57 UTC (rev 65871)
+++ trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h	2023-02-18 17:30:30 UTC (rev 65872)
@@ -1,4 +1,4 @@
 #ifndef luatex_svn_revision_h
 #define luatex_svn_revision_h
-#define luatex_svn_revision 7559
+#define luatex_svn_revision 7560
 #endif



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