From: Shane Carr Date: Tue, 27 Sep 2016 20:10:47 +0000 (+0000) Subject: ICU-12646 Handling out-of-bounds confusable entries in icu4j; see r39360 for icu4c. X-Git-Tag: milestone-59-0-1~117 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd47bd50e6810a551cbf129f02755004a93c1ada;p=icu ICU-12646 Handling out-of-bounds confusable entries in icu4j; see r39360 for icu4c. X-SVN-Rev: 39363 --- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/SpoofChecker.java b/icu4j/main/classes/core/src/com/ibm/icu/text/SpoofChecker.java index d221b428ca4..151c5aafbfa 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/SpoofChecker.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/SpoofChecker.java @@ -962,6 +962,12 @@ public class SpoofChecker { SPUString targetMapping = fTable.get(keyChar); assert targetMapping != null; + // Throw a sane exception if trying to consume a long string. Otherwise, + // codePointAndLengthToKey will throw an assertion error. + if (targetMapping.fStr.length() > 256) { + throw new IllegalArgumentException("Confusable prototypes cannot be longer than 256 entries."); + } + int key = ConfusableDataUtils.codePointAndLengthToKey(keyChar, targetMapping.fStr.length()); int value = targetMapping.fCharOrStrTableIndex;