Skip to content

Commit d4b340f

Browse files
committed
Improve robustness
1 parent 735f12e commit d4b340f

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

java/org/apache/tomcat/util/net/openssl/LocalStrings.properties

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ engine.ciphersFailure=Failed getting cipher list
1717
engine.emptyCipherSuite=Empty cipher suite
1818
engine.engineClosed=Engine is closed
1919
engine.failedCipherSuite=Failed to enable cipher suite [{0}]
20+
engine.failedToReadAvailableBytes=There are plain text bytes available to read but no bytes were read
2021
engine.inboundClose=Inbound closed before receiving peer's close_notify
2122
engine.invalidBufferArray=offset: [{0}], length: [{1}] (expected: offset <= offset + length <= srcs.length [{2}])
2223
engine.invalidDestinationBuffersState=The state of the destination buffers changed concurrently while unwrapping bytes

java/org/apache/tomcat/util/net/openssl/OpenSSLEngine.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,10 @@ public synchronized SSLEngineResult unwrap(final ByteBuffer src, final ByteBuffe
591591
throw new SSLException(e);
592592
}
593593

594-
if (bytesRead == 0) {
595-
break;
594+
if (bytesRead <= 0) {
595+
// This should not be possible. pendingApp is positive
596+
// therefore the read should have read at least one byte.
597+
throw new IllegalStateException(sm.getString("engine.failedToReadAvailableBytes"));
596598
}
597599

598600
bytesProduced += bytesRead;

webapps/docs/changelog.xml

+4
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@
166166
fully cleared, as there could be more than one error present after
167167
an operation (confirmed in the OpenSSL API documentation). (remm)
168168
</fix>
169+
<fix>
170+
Make handling of OpenSSL read errors more robust when plain text data is
171+
reported to be available to read. (markt)
172+
</fix>
169173
</changelog>
170174
</subsection>
171175
<subsection name="Web applications">

0 commit comments

Comments
 (0)