You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2018/02/05 23:30:03 UTC
svn commit: r1823262 - in /tomcat/trunk:
java/org/apache/tomcat/util/net/Nio2Endpoint.java webapps/docs/changelog.xml
Author: markt
Date: Mon Feb 5 23:30:03 2018
New Revision: 1823262
URL: http://svn.apache.org/viewvc?rev=1823262&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=61751
Fix truncated request input streams when using NIO2 with TLS.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1823262&r1=1823261&r2=1823262&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Mon Feb 5 23:30:03 2018
@@ -1146,8 +1146,26 @@ public class Nio2Endpoint extends Abstra
Future<Integer> integer = null;
if (block) {
try {
- integer = getSocket().read(to);
- nRead = integer.get(getNio2ReadTimeout(), TimeUnit.MILLISECONDS).intValue();
+ // When reading from an encrypted channel, a read of bytes
+ // from the network might result in zero application bytes
+ // after unwrapping.
+ // Since this is a blocking read, loop until application
+ // bytes are available.
+ // Since we are looping, ensure the timeout is updated for
+ // each loop.
+ long start = System.currentTimeMillis();
+ long timeout = getNio2ReadTimeout();
+ while (true) {
+ integer = getSocket().read(to);
+ nRead = integer.get(timeout, TimeUnit.MILLISECONDS).intValue();
+ if (nRead != 0) {
+ break;
+ }
+ timeout = timeout - (System.currentTimeMillis() - start);
+ if (timeout < 0) {
+ throw new TimeoutException();
+ }
+ }
} catch (ExecutionException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1823262&r1=1823261&r2=1823262&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Feb 5 23:30:03 2018
@@ -96,6 +96,10 @@
<subsection name="Coyote">
<changelog>
<fix>
+ <bug>61751</bug>: Fix truncated request input streams when using NIO2
+ with TLS. (markt)
+ </fix>
+ <fix>
<bug>62023</bug>: Log error reporting multiple SSLHostConfig elements
when using the APR Connector instead of crashing Tomcat. (csutherl)
</fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org