ICU-12646 Handling out-of-bounds confusable entries in icu4j; see r39360 for icu4c.

X-SVN-Rev: 39363
This commit is contained in:
Shane Carr 2016-09-27 20:10:47 +00:00
parent a1b7d39c3b
commit cd47bd50e6

View file

@ -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;