Author: markt
Date: Fri Apr 27 17:26:41 2018
New Revision: 1830373

URL: http://svn.apache.org/viewvc?rev=1830373&view=rev
Log:
Improve handing of overflow in the UTF-8 decoder with supplementary characters.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java?rev=1830373&r1=1830372&r2=1830373&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Decoder.java Fri Apr 27 
17:26:41 2018
@@ -278,6 +278,11 @@ public class Utf8Decoder extends Charset
                 outRemaining--;
             } else {
                 if (outRemaining < 2) {
+                    // Encoded with 4 bytes. inIndex currently points
+                    // to the final byte. Move it back to first byte.
+                    inIndex -= 3;
+                    in.position(inIndex - in.arrayOffset());
+                    out.position(outIndex - out.arrayOffset());
                     return CoderResult.OVERFLOW;
                 }
                 cArr[outIndex++] = (char) ((jchar >> 0xA) + 0xD7C0);

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1830373&r1=1830372&r2=1830373&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Apr 27 17:26:41 2018
@@ -94,6 +94,10 @@
         behaviour is enabled by default and configurable via the new Context
         attribute <code>allowMultipleLeadingForwardSlashInPath</code>. (markt)
       </add>
+      <fix>
+        Improve handing of overflow in the UTF-8 decoder with supplementary
+        characters. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to