Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerjung committed Apr 21, 2023
2 parents 2ef1ec2 + 4d963f8 commit a9bdd19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 9 additions & 3 deletions java/org/apache/tomcat/websocket/PerMessageDeflate.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,15 @@ public List<MessagePart> sendMessagePart(List<MessagePart> uncompressedParts) th
ByteBuffer uncompressedPayload = uncompressedPart.getPayload();
SendHandler uncompressedIntermediateHandler = uncompressedPart.getIntermediateHandler();

deflater.setInput(uncompressedPayload.array(),
uncompressedPayload.arrayOffset() + uncompressedPayload.position(),
uncompressedPayload.remaining());
if (uncompressedPayload.hasArray()) {
deflater.setInput(uncompressedPayload.array(),
uncompressedPayload.arrayOffset() + uncompressedPayload.position(),
uncompressedPayload.remaining());
} else {
byte[] bytes = new byte[uncompressedPayload.remaining()];
uncompressedPayload.get(bytes);
deflater.setInput(bytes, 0, bytes.length);
}

int flush = (uncompressedPart.isFin() ? Deflater.SYNC_FLUSH : Deflater.NO_FLUSH);
boolean deflateRequired = true;
Expand Down
8 changes: 8 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@
</add>
</changelog>
</subsection>
<subsection name="WebSocket">
<changelog>
<fix>
<bug>66575</bug>: Avoid unchecked use of the backing array of a
buffer provided by the user in the compression transformation. (remm)
</fix>
</changelog>
</subsection>
</section>
<section name="Tomcat 11.0.0-M5 (markt)" rtext="release in progress">
<subsection name="Catalina">
Expand Down

0 comments on commit a9bdd19

Please sign in to comment.