Ensure applicationDataLimit never exceeds plaintext limit
@@ -180,14 +180,12 @@ else if (!version.equals(readVersion))
int applicationDataLimit = 0;
if (type == ContentType.application_data)
- {
- if (readCompression instanceof TlsNullCompression)
- {
- applicationDataLimit = readCipher.getPlaintextLimit(length);
- }
- else
{
applicationDataLimit = getPlaintextLimit();
+
+ if (readCompression.getClass() == TlsNullCompression.class)
+ {
+ applicationDataLimit = Math.min(applicationDataLimit, readCipher.getPlaintextLimit(length));
}
}
