diff options
author | Karl Berry <karl@freefriends.org> | 2023-02-14 23:08:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-02-14 23:08:59 +0000 |
commit | bce2ca6c83dcf81678a5c631c178356f80202781 (patch) | |
tree | dc621392289de69bbdd6ac176e1b50f28f3b9719 /Build | |
parent | 7514e96579da6ac9cc6611d5cc86a40db8fe1677 (diff) |
fix for "Invalid unicode ranges in CMap beginbfrange operator", pdftex r898
git-svn-id: svn://tug.org/texlive/trunk@65837 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ChangeLog | 11 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/NEWS | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/tounicode.c | 23 |
3 files changed, 32 insertions, 4 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index 3b24ef24812..6f06138a6d0 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,14 @@ +2023-02-14 Thanh Han The <hanthethanh@gmail.com> + + * tounicode.c (set_glyph_unicode): take new glyph_unicode_entry arg. + (is_last_byte_valid): new fn. + (write_tounicode): stop writing range when last byte of a + beginbfrange is no longer valid, that is, >255. + Report from Ben JW: + https://tug.org/pipermail/tex-live/2023-February/048845.html + and corresponding veraPDF issue: + https://github.com/veraPDF/veraPDF-library/issues/1253#issuecomment-1420125850 + 2023-02-14 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> * wcfname.test: diff --git a/Build/source/texk/web2c/pdftexdir/NEWS b/Build/source/texk/web2c/pdftexdir/NEWS index 51dd3a08a16..e857a19fe0b 100644 --- a/Build/source/texk/web2c/pdftexdir/NEWS +++ b/Build/source/texk/web2c/pdftexdir/NEWS @@ -17,6 +17,8 @@ pdfTeX 3.141592653-2.6-1.40.25 - bugfixes: - finish omission of /Info dict when \pdfomitinfodict is not 0. + - generated beginbfrange should no longer be invalid with certain + characters (that is, no longer have have a last byte >255). pdfTeX 3.141592653-2.6-1.40.24 (TeX Live 2022) - changes: diff --git a/Build/source/texk/web2c/pdftexdir/tounicode.c b/Build/source/texk/web2c/pdftexdir/tounicode.c index 858954efde4..f90903b76c8 100644 --- a/Build/source/texk/web2c/pdftexdir/tounicode.c +++ b/Build/source/texk/web2c/pdftexdir/tounicode.c @@ -189,7 +189,7 @@ static char *utf16be_str(long code) * taking into account tfmname; in case it returns * gp->code == UNI_EXTRA_STRING then the caller is responsible for freeing * gp->unicode_seq too */ -static void set_glyph_unicode(const char *s, const char* tfmname, +static void set_glyph_unicode(const char *s, const char* tfmname, glyph_unicode_entry *gp) { char buf[SMALL_BUF_SIZE], buf2[SMALL_BUF_SIZE], *p; @@ -314,6 +314,19 @@ static void set_glyph_unicode(const char *s, const char* tfmname, } } +static boolean is_last_byte_valid(int srcCode1, int srcCode2, long code) +{ + /* + 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); +} + /* tfmname is without .tfm extension, but encname ends in .enc; */ integer write_tounicode(char **glyph_names, const char *tfmname, @@ -346,7 +359,7 @@ integer write_tounicode(char **glyph_names, const char *tfmname, pdftex_warn("Dubious encoding file name: `%s'", encname); } else { /* this is a builtin encoding, so name is e.g. "cmr10-builtin" */ assert(strlen(tfmname) + strlen(builtin_suffix) + 1 < SMALL_BUF_SIZE); - strcat(buf, builtin_suffix); + strcat(buf, builtin_suffix); } objnum = pdfnewobjnum(); @@ -389,8 +402,10 @@ integer write_tounicode(char **glyph_names, const char *tfmname, i++; } else { /* 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++; /* at this point i is the last entry of the subrange */ i++; /* move i to the next entry */ |