From 2f29d391e221968fa9587130e45fb5c914fbf8ae Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Tue, 7 Nov 2017 21:40:53 +0000 Subject: XeTeX_ext.c: Sync with the upstream. Guard against out-of-range result from UTF-8 decoding, and return U+FFFD Replacement Character instead. git-svn-id: svn://tug.org/texlive/trunk@45714 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/xetexdir/ChangeLog | 6 ++++++ Build/source/texk/web2c/xetexdir/XeTeX_ext.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/Build/source/texk/web2c/xetexdir/ChangeLog b/Build/source/texk/web2c/xetexdir/ChangeLog index 3e8fec002fc..8cfc5544af1 100644 --- a/Build/source/texk/web2c/xetexdir/ChangeLog +++ b/Build/source/texk/web2c/xetexdir/ChangeLog @@ -1,3 +1,9 @@ +2017-11-07 Jonathan Kew + + * XeTeX_ext.c: Guard against out-of-range result from UTF-8 + decoding, and return U+FFFD Replacement Character instead + to avoid a crash for invalid inputs (from A. Kakuto). + 2017-09-24 Hironori Kitagawa * xetex.web: Avoid overwriting prim_* entries by primitive(). diff --git a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c index 533423bf052..fa83bab8289 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c +++ b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c @@ -2786,6 +2786,10 @@ get_uni_c(UFILE* f) return 0xfffd; /* return without adjusting by offsetsFromUTF8 */ }; rval -= offsetsFromUTF8[extraBytes]; + if (rval < 0 || rval > 0x10ffff) { + badutf8warning(); + return 0xfffd; + } } break; -- cgit v1.2.3