6636363: BufferUnderflowException decoding length 6 UTF-8 sequences with direct buffers

Martin Buchholz martinrb at google.com
Sun Apr 20 02:32:43 UTC 2008


Xueming and/or Iris:

Here's a fix for

6636363: BufferUnderflowException decoding length 6 UTF-8 sequences
with direct buffers

This is a very obscure bug, but I like very much real bug fixes that
are smallest possible
i.e. change only one bit of the source code.

A regression test will be forthcoming once FindDecodingBugs.java and friends are
opened.

diff --git a/src/share/classes/sun/nio/cs/UTF_8.java
b/src/share/classes/sun/nio/cs/UTF_8.java
--- a/src/share/classes/sun/nio/cs/UTF_8.java
+++ b/src/share/classes/sun/nio/cs/UTF_8.java
@@ -326,7 +326,7 @@ class UTF_8 extends Unicode

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



More information about the core-libs-dev mailing list