Author: remm Date: Fri Feb 9 09:02:49 2018 New Revision: 1823620 URL: http://svn.apache.org/viewvc?rev=1823620&view=rev Log: Add minor HPACK fixes, based on fixes by Stuart Douglas.
Modified: tomcat/trunk/java/org/apache/coyote/http2/HpackDecoder.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/coyote/http2/HpackDecoder.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/HpackDecoder.java?rev=1823620&r1=1823619&r2=1823620&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/HpackDecoder.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/HpackDecoder.java Fri Feb 9 09:02:49 2018 @@ -280,21 +280,23 @@ public class HpackDecoder { * @param index The index from the hpack * @return the real index into the array */ - int getRealIndex(int index) { + int getRealIndex(int index) throws HpackException { //the index is one based, but our table is zero based, hence -1 //also because of our ring buffer setup the indexes are reversed //index = 1 is at position firstSlotPosition + filledSlots - return (firstSlotPosition + (filledTableSlots - index)) % headerTable.length; + int realIndex = (firstSlotPosition + (filledTableSlots - index)) % headerTable.length; + if (realIndex < 0) { + throw new HpackException(sm.getString("hpackdecoder.headerTableIndexInvalid", + Integer.valueOf(index), Integer.valueOf(Hpack.STATIC_TABLE_LENGTH), + Integer.valueOf(filledTableSlots))); + } + return realIndex; } private void addStaticTableEntry(int index) throws HpackException { //adds an entry from the static table. - //this must be an entry with a value as far as I can determine Hpack.HeaderField entry = Hpack.STATIC_TABLE[index]; - if (entry.value == null) { - throw new HpackException(); - } - emitHeader(entry.name, entry.value); + emitHeader(entry.name, (entry.value == null) ? "" : entry.value); } private void addEntryToHeaderTable(Hpack.HeaderField entry) { Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1823620&r1=1823619&r2=1823620&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Feb 9 09:02:49 2018 @@ -62,6 +62,9 @@ <add> Add async HTTP/2 parser for NIO2. (remm) </add> + <fix> + Add minor HPACK fixes, based on fixes by Stuart Douglas. (remm) + </fix> </changelog> </subsection> <subsection name="Web applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org