]> granicus.if.org Git - icu/commitdiff
ICU-12646 Handling out-of-bounds confusable entries in icu4j; see r39360 for icu4c.
authorShane Carr <shane@unicode.org>
Tue, 27 Sep 2016 20:10:47 +0000 (20:10 +0000)
committerShane Carr <shane@unicode.org>
Tue, 27 Sep 2016 20:10:47 +0000 (20:10 +0000)
X-SVN-Rev: 39363

icu4j/main/classes/core/src/com/ibm/icu/text/SpoofChecker.java

index d221b428ca44bb5115ee405233045e15d36bfd3b..151c5aafbfaf9aa7d71aa30419f3e7d72db1207b 100644 (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;