|
Evaluation
|
Yes. Here's the trivial fix to UTF_8.java:
@@ -322,15 +593,15 @@
((b4 & 0x3f) << 06) |
((b5 & 0x3f) << 00));
n = 5;
break;
case 12: case 13:
// 6 bytes, 31 bits
- if (src.remaining() < 4)
+ if (src.remaining() < 5)
return CoderResult.UNDERFLOW;
if (!isContinuation(b2 = src.get()))
return CoderResult.malformedForLength(1);
if (!isContinuation(b3 = src.get()))
return CoderResult.malformedForLength(2);
if (!isContinuation(b4 = src.get()))
return CoderResult.malformedForLength(3);
Posted Date : 2007-12-01 18:53:02.0
Here's a change to the test case FindDecoderBugs.java
that checks long UTF-8 sequences.
@@ -287,21 +287,27 @@
System.out.printf("Testing prefix %s%n", string(prefix));
test(prefix);
testExhaustively(prefix, 1);
testExhaustively(prefix, 2);
// Can you spare a week of CPU time?
- // testExhaustively(cs, tester, prefix, 3);
+ // testExhaustively(prefix, 3);
testRandomly(prefix, 3);
testRandomly(prefix, 4);
+ if (cs == utf8) {
+ testRandomly(prefix, 5);
+ testRandomly(prefix, 6);
+ }
}
}
+ private final static Charset utf8 = Charset.forName("UTF-8");
+
private final static Random rnd = new Random();
private static byte randomByte() {
return (byte) rnd.nextInt(0x100);
}
private static byte[] randomBytes(int len) {
byte[] a = new byte[len];
for (int i = 0; i < len; i++)
Posted Date : 2007-12-01 18:53:02.0
|