Fix BZ 64830 - concurrency issue in HPACK decoder · apache/tomcat@d56293f · GitHub
Skip to content

Commit

Permalink
Fix BZ 64830 - concurrency issue in HPACK decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Nov 9, 2020
1 parent 935fc55 commit d56293f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 4 additions & 8 deletions java/org/apache/coyote/http2/HpackDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public class HpackDecoder {
private volatile boolean countedCookie;
private volatile int headerSize = 0;

private final StringBuilder stringBuilder = new StringBuilder();

HpackDecoder(int maxMemorySize) {
this.maxMemorySizeHard = maxMemorySize;
this.maxMemorySizeSoft = maxMemorySize;
Expand Down Expand Up @@ -222,19 +220,17 @@ private String readHpackString(ByteBuffer buffer) throws HpackException {
if (huffman) {
return readHuffmanString(length, buffer);
}
StringBuilder stringBuilder = new StringBuilder(length);
for (int i = 0; i < length; ++i) {
stringBuilder.append((char) buffer.get());
}
String ret = stringBuilder.toString();
stringBuilder.setLength(0);
return ret;
return stringBuilder.toString();
}

private String readHuffmanString(int length, ByteBuffer buffer) throws HpackException {
StringBuilder stringBuilder = new StringBuilder(length);
HPackHuffman.decode(buffer, length, stringBuilder);
String ret = stringBuilder.toString();
stringBuilder.setLength(0);
return ret;
return stringBuilder.toString();
}

private String handleIndexedHeaderName(int index) throws HpackException {
Expand Down
3 changes: 3 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
Add additional debug logging for I/O issues when communicating with the
user agent. (markt)
</add>
<fix>
<bug>64830</bug>: Fix concurrency issue in HPACK decoder. (markt)
</fix>
</changelog>
</subsection>
<subsection name="Jasper">
Expand Down

0 comments on commit d56293f

Please sign in to comment.